I have a question concerning visual studios built in test suite. Is VS studio running these tests with some special compiler flags applied?
The problem description is as following.
I have overloaded the Equals
function on one of my classes.
During test runs it would be nice, if it could give me some additional information, which members in the class aren't equal at all.
Therefore I'd like to implement some messages only if the application is running in test mode.
Thanks for any reply! Andreas
To run all the tests in a default group, choose the Run icon and then choose the group on the menu. Select the individual tests that you want to run, open the right-click menu for a selected test and then choose Run Selected Tests (or press Ctrl + R, T).
Unit Testing is done during the development (coding phase) of an application by the developers. Unit Tests isolate a section of code and verify its correctness.
All you have to do is: Right click your test function name. Select Run Test or Debug Test.
VS compiles/builds the projects with the currently selected build configuration. So a solution might be to create a separate build configuration yourself, and then use a constant (e.g. TEST) for the projects in that particular build configuration. The output method execution can then be restricted either with the #if TEST
directive or with the [Conditional("TEST")]
attribute. You could configure your build server te allways run the tests with that particual build configuration, so you would see additional output. You would however need to switch between the build configurations manually when running the tests from VS
Create a new solution configuration "Test" (if you don't have it yet) and switch to it. Open project settings, switch to the Build tab and define a new symbol TEST. Press OK.
Change your Equals implementation to
public override bool Equals (object obj)
{
#if TEST
// Your implementation
#else
return base.Equals (obj);
#endif
}
This will compile a different method body for your test configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With