|
|
-
Just like design patterns, the use of test patterns will make your life easier. A lot of the common testing methods can be reused. Along with the benefits of reuse, using patterns makes it easier to explain to others what you are going to do in a word or a two instead of telling the whole story. Moreover, test patterns provide guidelines for solving common test design problems and define measurable actionable methods of testing. Test patterns have certain attributes that shape the pattern. It has an easy to remember name, which people agree upon and use to refer to the same test method. The pattern should be used to solve a certain problem, the same problem can be addressed by multiple problems, however, a pattern should tackle one problem and focus on its solution. Analysis of the problem addressed by the pattern is very important as it shows the various dimensions of the problem and why this pattern is the best solution for it. Test patterns are basically design patterns to solve testing problems; it has to have an algorithm or a sequence that forms the solution and shows how the test cases will be implemented. When test cases following this pattern are run, they will yield results that should be expected by the oracle of the pattern. And to make it easier for others who are going to use the pattern, it should list some examples, and how it relates to other patterns; a pattern doesn’t have to have related patterns though. To be explicit about when the pattern should be used and when it’s not suitable for the task at hand, limitations and restrictions should be listed too. Overall, these are the key attributes of a pattern, but there might be other attributes that can be added to specific patterns. Using patterns is recommended, because it’s conventional and standardized, but sometimes we face unusual problems that require unusual solutions. If a solution is so unique, specific, and is not likely to be reused, it may not be a good candidate for a test pattern. This doesn’t mean that patterns discourage innovation in problem solving, on the contrary, a pattern can get replaced by a better one solving the same problem. So, sharing the better solution among teams, or better among a community members is a good opportunity to create a new pattern. For more info: http://www.hwtsam.com and http://msdn.microsoft.com/en-us/library/cc514239.aspx
|
-
To do this, you can't call query labels with a wildcard character, you need to do the following: - Get all items blow $/Dir1 using GetItems - Loop through them calling QueryLabels on each one. Here's a code snippet:
VersionControlServer sc = tfs.GetService<VersionControlServer>(); List<VersionControlLabel> labels = new List<VersionControlLabel>(); foreach (Item i in sc.GetItems("$/Proj", RecursionType.Full).Items) { labels.AddRange(sc.QueryLabels(null, null, null, false, i.ServerItem, null)); }
|
-
A very handy power tool is tfpt unshelve. It’s capable of migrating a shelveset from a branch to another, it does that by performing a baseless merge, so you will need to resolve the conflicts produced. The syntax of the command looks like the following: tfpt unshelve shelvsetName /migrate /source:$/SourceBranch /target:$/TargetBranch
|
-
You can receive a daily email that has a compiled list of notifications, but you will need to subscribe programmatically:
IEventServiceeventService = (IEventService)new TeamFoundationServer("http://tfs:8080").GetService(typeof(IEventService)); string filter = "'Artifacts/Artifact[starts-with(translate(@ServerItem,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwxyz\"),\"$/TeamProject/Folder\")]' <> null AND \"Committer\"<> 'DOMAIN\\YourUserName'"; DeliveryPreference dp = new DeliveryPreference { Address = "user@example.com", Schedule = DeliverySchedule.Daily, }; eventService.SubscribeEvent(@"DOMAIN\userName", "CheckinEvent", filter, dp);
|
-
-
You can run: tf diff /shelveset:shelvesetName;DOMAIN\ownerUserName Please note that this will diff the shelved changes against the unmodified version, not necessarily the latest version, just like what the you get from clicking compare in the shelveset details dialog. If you want to diff the shelved files programmatically against the latest version, you will need to write some code, please take a look at: http://blogs.msdn.com/mohamedg/archive/2009/03/08/how-to-diff-files-using-tfs-apis.aspx. If you are going to use the Difference class to launch a diff tool, you can use Difference.VisualDiffItems. If you need to get the differences in a linked list of DiffSegments, you will need to unshelve the shelved file (fileA) and download the latest from server (fileB) to disk first, then diff them using the following call: Difference.DiffFiles(fileA, FileType.Detect(fileA, null), fileB, FileType.Detect(fileB, null), new DiffOptions());
|
-
You can achieve that behavior by running:
tf hist rootItemSpec /r /version:LstartLabel~LendLabel
Here’s my scenario:
tf hist /i File.cs
Changeset Change User Date Comment
--------- -------------------------- ------------- ---------- --------
65 edit mohamedg 4/2/2009
63 edit mohamedg 4/2/2009
60 edit mohamedg 4/2/2009
59 edit mohamedg 4/2/2009
50 edit mohamedg 4/1/2009
49 edit mohamedg 4/1/2009
48 edit mohamedg 3/31/2009
47 add mohamedg 3/31/2009
tf label Rev1 File.cs;48
Created label Rev1@$/Proj
tf label Rev2 File.cs;63
Created label Rev2@$/Proj
tf hist /i File.cs /version:LRev1~LRev2
Changeset Change User Date Comment
--------- -------------------------- ------------- ---------- --------------------------------
63 edit mohamedg 4/2/2009
60 edit mohamedg 4/2/2009
59 edit mohamedg 4/2/2009
50 edit mohamedg 4/1/2009
49 edit mohamedg 4/1/2009
|
-
You can use tfpt history /followbranches to follow the history of an item across branches. We are looking into supporting this in the history dialog in the next version. You can see which versions are ported over during the merge operation if you use tf.exe: tf merge BranchA BranchB /r merge: $/mohamedg/blog/BranchA/File.cs;C663~C664 -> $/mohamedg/blog/BranchB/File.cs;C665 After the merge is done, you can look up the merge history to know what changesets were ported over, for example: tf merges BranchA BranchB /r Changeset Merged in Changeset Author Date --------- ------------------- -------------------------------- ---------- 654 655 mohamedg 4/10/2009 656 657 mohamedg 4/10/2009 658 661 mohamedg 4/10/2009 659 661 mohamedg 4/10/2009 660 661 mohamedg 4/10/2009 662 665 mohamedg 4/10/2009 663 665 mohamedg 4/10/2009 tf merges BranchA BranchB /r /format:detailed /showall Merged items: $/mohamedg/blog/BranchA;C654 -> $/mohamedg/blog/BranchB;C655 $/mohamedg/blog/BranchA/File.cs;C654 -> $/mohamedg/blog/BranchB/File.cs;C655 $/mohamedg/blog/BranchA/File.cs;C656 -> $/mohamedg/blog/BranchB/File.cs;C657 $/mohamedg/blog/BranchA/File.cs;C658~660 -> $/mohamedg/blog/BranchB/File.cs;C661 $/mohamedg/blog/BranchA/File.cs;C662~663 -> $/mohamedg/blog/BranchB/File.cs;C665
|
-
If you have an IDE that uses the MSSCCI provider, like VS 2003 or VB6, and you want to switch between TFS and VSS because you have projects on both systems, you will have to change the provider every time you switch. The thing is that setting is stored in the Windows registry, therefore, you will have to restart the IDE to enable the desired provider (just like most programs, unless they implement a registry watcher). There are some tools that can make the switch easier: http://www.codeproject.com/KB/applications/sccswitcher.aspx http://www.sitedev.com/sccswitcher http://weblog.kilic.net/tools/SCPSelector Or you may create your own .reg file to write to the registry.
|
-
Well, the answer to this one is pretty easy and straight-forward. You can accomplish that using a check-in policy. For example, to force users to link check-ins to work items that are not closed, you may do the following: - Add a Team Query to the desired project, call it "Not Closed" and specify the condition State <> Closed
- Right click the team project > Team Project Settings > Source Control > Check-in Policy > Add, then scroll down to choose "Work Item Query Policy", click OK
- In the "Choose Your Query" dialog, choose "Not Closed" and click OK
Now, after you added this check-in policy, the user should link the changeset to a work item of the "Not Closed" query or provide a policy-override reason.
|
-
TFS uses a temp folder to get files that you view. The location of that folder is %TMP%\TFSTemp. It’s not configurable via TFS, tf.exe, or Visual Studio. However, you can just set the TMP environment variable. Simply: set TMP=D:\Temp set TEMP=%TMP% md %TMP% Then you can starting using tf.exe afterwards and it will use the new %TMP%\TFSTemp instead, same thing with Visual Studio which can be started by running devenv.exe If you want to change TFS temp folder on the server side too without changing the system temp folder, you have to have IIS7 installed; IIS7 loads user's profile by default for all application pools, including environment variables. Which means that the temp dir for the app pool is its user's temp dir, and you can change this value for that specific user only, not the system value. Another temp folder on the server will be %TMP%\TFLogFiles. It’s used by TFS to log tracing info. This location is configurable in the global web.config, it’s an appSetting and its key is called traceDirectoryName.
|
-
Using tf.exe gives you more options and more control, here are some tips that might come handy: For item specs: - You can use wildcards with most of the commands
- Just like most command-line apps, you can supply relative path parts (like . and ..), you can use \ to designate the root of the drive, and you can use UNC paths
- You also can use server paths (designated by $/), some times you have too (like in tf destroy)
- Most of the commands will accept more than one item spec at a time
For version specs: - These values can be passed to the /v (/version) option or appended to the item spec to specify a certain version of the item:
- A changeset number can be used directly or optionally preceded with the prefix C. For example: File.cs;C123
- Labels are preceded with the prefix L, to use a label that contains spaces use double quotes. For example: File.cs;L"Good Build"
- Any .Net DateTime format can be used to specify the date-time of a version, and it should be preceded with the prefix D. For example: File.cs;D"2009-04-01"
- To use the current workspace version, you can use the letter W, or you can use it as a prefix for another workspace’s version. For example: File.cs;WotherWs;DOMAIN\username or File.cs;W
- For the tip (latest) version, just use the letter T. For example: File.cs;T
Options aliases: | Option | Alias | | /changeset | /g | | /comment | /c | | /computer | /m | | /delete | /d | | /force | /p | | /format | /f | | /help | /? or /h | | /lock | /k | | /login | /y | | /newname | /n | | /noprompt | /i | | /owner | /o | | /recursive | /r | | /server | /s | | /slotmode | /x | | /template | /t | | /user | /u | | /version | /v | | /workplace | /w |
|
-
A common scenario that you may see is the need to share/sync workspace mappings amongst team members. A developer adds a new dependency in a certain project and changes his/her mappings to get this library, and everyone else in the team now needs to do the same thing. Since workspace mappings are stored on the server, you can copy the mappings of any workspace to any of your workspaces, or create a new workspace using a template from another workspace. For example, let's say that you maintain the master workspace that everyone else is required to clone, once this workspace is changed, you can email your team so that they update their mappings. To view mappings of your workspace, they can run: tf workspace /s:http://tfs:8080 WorkspaceName;DOMAIN\YourUserName Then the workspace dialog will pop up and they can select all mappings (Ctrl+A) then copy them (Ctrl+C), then edit mappings in their workspaces by pasting the new mappings over the old ones. Another option is to create a batch file that runs the same command above with the /i option, finds the mappings, parses them in a FOR loop to run tf workfold /map on each one, it should look like the following: FOR /F "tokens=1,2,3 delims=:" %i IN ('tf workfold /s:http://tfs:8080 /w:MasterWorkspaceName;DOMAIN\YourUserName ^| find "$/" ^| find /v "(cloaked)"') DO tf workfold /map "%i" "%j:%k" /s:http://tfs:8080 /w:localWorkspaceName Please note that if you run this command on the command prompt directly, variables like i should be written as %i, while if you run it using a batch file, it should be written as %%i
|
-
One of the new features added in VSTF 2008 SP1 is that you can switch to another branch in your workspace and you don’t need to download all the files of the new branch. TFS will only download the files that differ in the new branch, if you use tf get /remap. It will also tell the server that you’re changing the association of the local items that you were mapped to the old branch, after running the command, they will be associated with the new branch. From MSDN on using Get with the /remap option: The /remap option saves download time when you remap a local folder to a new or different branch. For example: -
You map $/branch1 to D:\branch on your computer. -
You run tf get to get a copy of all the items from $/branch1 to the local folder. -
You change the mapping of $/branch1, and then map $/branch2 to the local folder previously mapped as $/branch1 (D:\branch). -
You run tf get with the /remap option to only download the content in $/branch2 that differs from content in $/branch1 on the local folder (D:\branch).
|
-
A common problem occurs when the drive that contains your workspaces runs out of disk space, or when you find yourself in a situation that you have to move your workspace to another drive. This might get tricky because your workspace mappings are stored on the server side. TFS knows about the local path and version of the items you have on disk, hence you can’t change the drive letter without telling the server that you did so. The easy way out is to maintain the same drive letter after you move the workspace to the new drive. Simply change the drive letter to the one used in the mappings, you can use compmgmt.msc (Computer Management) to accomplish that. If you can’t change the drive letter, for example if it’s the system drive, you can tell NTFS to link the old path of the root folder of your workspace to the new one using a junction. To create an NTFS junction point, you can download junction.exe and run: junction <junction directory> <junction target>
|
|
|
|