The TddHelper extension is designed to simplify your life if you do Test-Driven Development. It is a helper utility that exposes commands to move to the next tab group, split windows, and jump to test or implementation files (C# only). If a test or implementation file is not found, the utility can create both test/implementation classes and projects. For created projects, automatic references to unit testing framework is supported, and friend assemblies (also strong-named ones) are supported.
The extension tries to support both jumping from Test -> Implementation and vice-versa. This also applies to class and project creation – you can create the test project first and test class, strong-name the test project and add your unit-test framework assembly and then create the implementation assembly just by jumping to the non-existing implementation. When creating test projects, a reference to the test framework is added automatically if so configured.
Tested on Visual Studio 2013 only for now. Have not tested with Visual Studio 2015. Probably won’t work with VS 2010, VS2012 (not tested).
There are three options to install the extension
Source code for the Extension lives on https://github.com/brunzefb/TddHelper. Feel free to fork. You can also send me a pull request through github if you have bug fixes/enhancements.
License / Disclaimer of Warranty / Limitations of Liability
Software is provided under the Apache License 2.0 license. It says that there’s no warranty, and that you are getting this Tdd Helper extension “as is”, and that the author is not responsible anything that goes wrong as a result of you installing this software.
If you find a bug, please add it to the issue tracker on github. https://github.com/brunzefb/TddHelper. You also can email me at brunzefb_AT_gmail.com, please put TddHelper in the subject line.I will only respond if an issue has been created. The extension generates comprehensive logs info stored in C:\ProgramData\TddHelper\TddHelper.log, so please attach the log file to the issue along with what you were doing at the time.
Version 1.0 - November 2013, Proof of concept, Jumping Tabs
How do I know the install worked?
The Extension adds three new menu items to the Visual Studio Tools menu:
The menu items are a bit lame – they work but it is way better to use the keyboard shortcuts.
Warning! The Intel graphics chipset utility maps the Ctrl+Alt+Right Arrow to rotate the screen. That functionality can be disabled in the Intel utility. Ctrl+Alt+Up Arrow restores the orientation if you get stuck. Check the Keyboard mapping section at the end of this document for more information.
Jump Left and Right between Tab Wells Using the Keyboard
Unfortunately, Visual Studio does not expose keyboard shortcuts to move between two tab wells. This extension solves this problem. To try it do the following:
The resulting screen should look similar to this:
Tip: You can assign the command Window.MovetoNextTabGroup and Window.MoveToPreviousTabGroup to move the highlighted tab to the next/previous tab group. My keyboard mapping for this is Ctrl + Shift + Alt + =.
Goto Test / Implementation
Tip: When you have duplicate files a conflict resolution dialog will pop up. This helps you locate the correct file. Once you select the correct file, you choice is remembered – this works on a per solution basis. The dialog is shown below:
TDD Helper Options Explained
Options can be accessed by going to the Visual Studio Tools->Options and locating the Tdd Helper section:
Test file suffix: The Extension works by using a naming convention to map between Unit tests and implementation. If you implementation is File.cs and your test is FileTest.cs, then choose Test.cs for the suffix. If your implementation is File.cs and your test is FileUnitTest.cs, then choose UnitTest.cs for Test file suffix.
Project suffix: Not currently used, leave this as is.
Editing Layout: Gives options to place your unit tests either left, right (using split window) or just to use a single multi-tabbed window.
Clean Mode: Saves everything, closes all the windows and then just reloads Test and implementation in the correct layout. This is useful as it focuses the view on just the test and the class under test. If this is not selected, Tdd Helper will try to keep the other windows open – it will just close the test and implementation files and re-open them in the preferred location.
Create Class Automatically: Tdd Helper maintains an association between Implementation and Test project. The association is created when you try to jump to a non -test or implementation, and is persisted on a solution basis. If Create Class Automatically is checked then missing implementation/test classes are created automatically in the associated project. Unchecking this checkbox will cause the system to prompt you before creating a class.
Mirror Project Folders when creating class. If you check this, Test/Implementation classes are created in the same Solution Folder hierarchy. E.g if . .\project\Subfolder1\Subfolder2\impl.cs is active and you jump to test/implementation, a new \projectTest\Subfolder1\Subfolder2\implTest.cs will be created. Left unchecked, a new \projectTest\implTest will be created.
Make new test project friend of implementation project. If jump to a non existing test/implementation, the system will prompt you to pick or create a project. If you create a project and have this option selected, then an [Assembly:InternalsVisibleTo(..)] directive will be added to your implementation’s AssemblyInfo.cs file. TddHelper knows about strong-names – so the proper public key is automatically added in a user-friendly way without running Sn.exe –Tp. Having the box unchecked means that TddHelper leaves your AssemblyInfo.cs files alone.
When creating Test Project, add references to Unit Testing Framework automatically. Does what it says. The options on how the unit test framework is added (and what framework) are on the “Test Assembly Reference” options page, which is shown below:
Clear File Cache Button: The extension maintains a per-solution persisted file association cache. Say you have a file called Program.cs and there are two ProgramTest.cs files in your test project. If you Program.cs is active and you jump to the test file, you will be presented with a dialog to help resolve the conflict, ie to pick one or the other file. Your choice is then persisted and when you jump to the Test file the next time, the remembered choice will be used. If for some reason you picked the wrong file, you can clear the cache with the Clear File Cache Button.
Clear Project Cache Button: In order to create test/implementation files, a project must be specified. The user is presented with a dialog to either pick an existing project or to create a new project where the test/implementation will be created. This choice is persisted on a per-solution basis. If you wish to be prompted again as to where new test/implementation files are stored, hit the clear project cache button.
Tip: Internally, absolute paths are used – if you move your project from one location to another on the disk, you may want to clear the caches.
Test Assembly Reference Options Page
Use NuGet to add Reference to Unit Testing Framework: If selected uses the specified package id and version to install (from default package source). Check on NuGet.org to find out the exact Package Id and Version. WARNING: If you get this wrong, it will most likely silently fail. Try the Package Manager console window to make sure you get spelling and version right.
Set Unit Test Assembly to add to Test Project: Sometimes it is nice not to use the package manager. Just select this option, and then click browse to locate your unit testing framework assembly. A reference to that assembly file is then added, just like if you were to reference it manually.
Remapping Keyboard shortcuts
Use the Tools->Customize->Keyboard… Dialog to customize the keyboard keystrokes.
Are the exposed commands. You may need to disable existing shortcuts to get things to work properly. Check the “Shortcut currently used by” combo and examine the contents carefully.