Reputation: 811
I have a straightforward unit test class like so:
[TestClass]
public class SomeTests
{
[TestMethod]
public void Test1()
{
// make some assertions
}
[TestMethod]
public void Test2()
{
// make some assertions
}
// ...
[TestMethod]
public void Test50()
{
// make some assertions
}
}
and I basically want to run Test1..Test50 twice via the "Run All" command. Once with App.config like so:
<appSettings>
<add key="SomeSetting" value="true"/>
</appSettings>
and once with App.config like so:
<appSettings>
<add key="SomeSetting" value="false"/>
</appSettings>
Being lazy, I don't want to refactor & parameterize 50 tests. And obviously I don't want 50 duplicate tests.
I'm having a bit of a brain fart over this, apologies if it's blindingly obvious.
Upvotes: 1
Views: 1013
Reputation: 6222
Create two Test Settings. Click Enable Deployment under the Deployment section. Add your two different App.Config files (one to each Test Settings). Execute your tests, then swap to the other TestSettings and execute them again.
Might be a way to run with all testsettings, but I haven't found it.
Upvotes: 0
Reputation: 1753
make SomeTests abstract.
Add two new projects, with the two different .config files.
In each project add a TestClass that inherits from SomeTests.
Run all will now run both sets of tests.
Upvotes: 1