MSTest Unit test attributes check - visual-studio-2010

For regulatory reason all unit tests in our solution have to have some attributes set. Is there a way to check in visual studio if some specific attributes (like CREATOR, REVIEWER, REVIEWDATE, ...) are set within the VSMDI-list of the solution?
Further I have to check if the "CREATOR" attribute is equal to the "REVIEWER" attribute.
The goal is to deliver a list (Text, Excel, whatever) to my Scrum team with all these "wrong set attributes", so that they can fix them.

You can use reflection to check for the attributes and then create your Excel/Text list. You can do this as a MSBuild task and plug it into pre/post build actions of your Unit test project. See this blog post for an example on how to create a custom MSBuild task.

After running all the needed Tests within Visual Studio 2010 you get a TRX-file containing all the details of the executed tests. If you have put some attribute on these tests,you'll find them also in the TRX-file. Now you have to write an XML parser to read the attributes you need and work with this data. I extracted them into Excel and worked further with the data into the Excel map.

Related

Visual Studio Ordered Tests - Different Projects

I have created a number of (separate) CodedUI projects within Visual Studio 2013, in order to test the basic functions of a website.
Test-cases are created as separate projects, as I expect some (or all?) of them to change over time, and thus to ensure 'modularity' of capture for ease of subsequent maintenance.
Now, I see I can easily create an Ordered Test within each project, which will allow the same test-case to be run and re-run as many times as I wish; But, it's not obvious to me how I can create an Ordered Test whereby I can add different test-cases created as different projects. Certainly, not directly.
Is it possible?
Also, can I rename the Ordered Test list and save it to a separate folder where I can store differing Ordered Tests to test functionality, as I wish?
Ideally, I'd like to create an Ordered Test external to any specific project, so I can go into any project I wish and add whatever tests I wish, as the test-environment is always the same.
you should have created a single project for your application. To ensure 'modularity', coded ui has given us the option of creating different UI Maps within a same project. Each UI MAP will represent a module of your application. This approach will give you easy maintenance and it will also help you to create ordered test cases which contain test cases from different UI Maps.
for more details please see this link
https://msdn.microsoft.com/en-us/library/ff398056.aspx
Thanks
Yes, I sort of see that. And I guess it's easy enough to move the code to become separate 'solutions' within a 'project'.
However, I want to work with TFS server too, so will look at the MTM route as well.
But it may be that I need my captured CodedUI to be 'solutions' within a single project too - though I really want my modules to be 'stand-alone' projects for safe-keeping.
Will investigate further.

what's the purpose of *.vsmdi? Do I need to source control it?

What's the purose of .vsmdi file? Do I need to check into the source control system?
The VSMDI file is created by Visual Studio when you create a test project for the first time. It contains a list of all tests that Visual Studio can find in your solution assemblies and allows you to divide your tests into so-called test lists. These test lists can be used to categorize your tests and let you select a subset of tests for execution.
You can use this mechanism for running sub-selections. However, you can also (freely) assign multiple test categories to a test, which enables you to achieve the same, in a more flexible way. And with the known issues with VSMDI files, like uncontrolled duplication of these files and obsolete tests being listed with a warning icon, it might seem the better way to do things like this.
My overall suggestion is: check-in your default generated .vsmdi file. This will prevent Visual Studio from (re-)generating such files on your own and your team members systems when new test projects are added. Decide on usage of test lists or assigning categories to tests directly based on your usage experience. Test lists are easy to start with, but less suitable is you want to have flexibility for a large set of tests.
It's used for Testing in Visual Studio. If you don't do testing in Visual Studio, I wouldn't worry about it. But if you do, and you have hundreds of tests it might be worth keeping.

Feature Builder multiple projects and parameters

I am using Visual Studio Feature Builder to create a new Guidance in my office. Everything was working fine until I smashed my head against the multiple project template.
When you create a multiple project template it looks like there is now way to propagate parameters value in the child project of the template solution.
Any idea or tutorial or whatever as I am going mad with this.
If, for example, want to retrieve some value that is available within the template substitution dictionary, you can do this by adding a binding/command combination to the BeforeUnfold property of your VSTemplateLaunchPoint.
When the command executes, you can inspect the TemplateReplacementsDictionary which is available by accessing FeatureCallContext.Current.TemplateReplacementsDictionary.
The value of this variable is not valid in the AfterUnfold situation. However, you can access the Blackboard inside the command you bind to BeforeUnfold if you wish to save user inputs.
The same dictionary should be used for all projects in your multi-project template.

How do I pass custom action data from a Visual Studio Setup MSI to an output project via a Merge module

I have a fully working Setup project within Visual Studio 2008 that takes inputs from a UI and passes them via a Custom Action to the output - this works perfectly.
Now I have to change this so that the UI is still in a setup project but that the output is within a merge module.
The current Custom Action Data looks much like the following with EditHostUrl coming from a UI dialog editbox.
/HostUrl="[EditHostUrl]"
I now need to pass this value to the merge module and then from there use it as an input for the custom action data to the project output but there does not seem to be any documentation on how to achieve this.
To be clear Wix/InstallShield etc... are not currently options. I would also rather not embed the UI within the merge module (for reasons of separation and also it's not supported out of the box with visual studio).
The answer turned out to be reltively simple.
When the Merge Module is included into the Setup project it is truely merged and as such the MergeModule can read values from the parents UI variables as if they were its own. I had other difficulties making this non-apparent to begin with but when creating the modules and setup projects from scratch the values are in the same context.

Can I generate values for a custom parameter such as a timestamp for a Visual Studio Item Template?

I would like to include the current timestamp as part of a Visual Studio Item Template (the timestamp of when the file is created by the user). Is this possible?
It's really simple. There are several built-in replacement parameters that you can use. For a timestamp, include $time$ in the template. It will be replaced by the current date and time in the format DD/MM/YYYY HH:MM:SS.
Check this excellent guide: Create Reusable Project And Item Templates For Your Development Team
You can cause code to be executed when a template is expanded by implementing a wizard. The wizard need not have a user interface, but can populate a dictionary of name/value pairs. The values can then be substituted into the template.
Look in the Visual Studio SDK documentation for the topic named "How to: Use Wizards with Project Templates". I believe you can also use a wizard in an item template.
Also, take a look at the Guidance Automation Toolkit, which provides a declarative way to create wizards, among many other things.

Resources