Skip to content

Commit f75889e

Browse files
Mohammad DehghanMohammad Dehghan
authored andcommitted
Kill sample app after each test, to speed up tests
1 parent ede53cf commit f75889e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

SG.CodeCoverage.Tests.NetFx/InstrumenterTester.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ public void ExitApp()
113113
{
114114
CheckAppStarted();
115115
_process.StandardInput.WriteLine("exit");
116-
if (!_process.WaitForExit(10000))
117-
throw new Exception("App did not exit withing 10 seconds.");
116+
if (!_process.WaitForExit(20000))
117+
throw new Exception("App did not exit withing 20 seconds.");
118+
_process.WaitForExit();
119+
_process = null;
120+
}
121+
122+
public void KillApp()
123+
{
124+
CheckAppStarted();
125+
_process.Kill();
118126
_process.WaitForExit();
119127
_process = null;
120128
}

SG.CodeCoverage.Tests.NetFx/TestInstrumentation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void Coverage_Startup()
2626
{
2727
_tester.RunApp();
2828
AssertVisitedFilesAndMethods(Files.Startup, Methods.Startup);
29+
_tester.KillApp();
2930
}
3031

3132
[TestMethod]
@@ -38,6 +39,7 @@ public void Coverage_IsPrime1()
3839
Methods.Startup
3940
.Concat(Methods.RunCommand)
4041
.Concat(Methods.PrimeCalculator.IsPrimeAndIsLessThan2));
42+
_tester.KillApp();
4143
}
4244

4345
[TestMethod]
@@ -51,6 +53,7 @@ public void Coverage_IsPrime4()
5153
.Concat(Methods.RunCommand)
5254
.Concat(Methods.PrimeCalculator.IsPrimeAndIsLessThan2)
5355
.Concat(Methods.PrimeCalculator.GetUpperBound));
56+
_tester.KillApp();
5457
}
5558

5659
[TestMethod]
@@ -66,6 +69,7 @@ public void Coverage_IsPrime7()
6669
.Concat(Methods.PrimeCalculator.IsPrimeAndIsLessThan2)
6770
.Concat(Methods.PrimeCalculator.GetUpperBound)
6871
.Concat(Methods.SampleStruct));
72+
_tester.KillApp();
6973
}
7074

7175
[TestMethod]
@@ -80,6 +84,7 @@ public void Coverage_ResetHits_IsPrime2()
8084
Methods.RunCommand
8185
.Concat(Methods.PrimeCalculator.IsPrimeAndIsLessThan2)
8286
.Append(Methods.get_Commands));
87+
_tester.KillApp();
8388
}
8489

8590
[TestMethod]

0 commit comments

Comments
 (0)