I have 3 projects. Call them project A, B and C. Those projects have very similar functionality even though they have nothing to do with each other. By researching on the internet I see people place their unit tests on the project they are working on.
Let me explain why I find it helpful to create one unit test project that test all the projects instead of 3 unit tests projects.
This is the pattern I am using:
[Test]
public void TestFoo()
{
var filter = SystemType.ProjectA | SystemType.ProjectC; // Need to test this on projectA and ProjectB
// linuxSystems are the computers where I perform the tests
var linuxSystems = Globals.LinuxSystemsToTest();
foreach (var ls in linuxSystems)
{
// do not test if flag is not precent
if (filter.HasFlag(ls.SystemType) == false)
return;
ls.Connect();
var output = ls.RunCommand("sudo cat /var/someFile");
Assert.IsTrue(output.Contains("foo"));
// perform test
}
}
If I decide to create a Unit Test project per project (having 3) then I will have to create 2 unit tests calling the same base class. Moreover, when adding a new test if I need to test that on all 3 projects I will have to open the 3 projects and add the test on each project instead of just having the line var filet = SystemType.ProjectA | SystemType.ProjectB | SystemType.ProjectC;
. Having one project will prevent me from having to do all that.
What will be the best pattern that you guys recommend for testing my 3 projects?
Aucun commentaire:
Enregistrer un commentaire