diff --git a/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommand.cs index 9be0a7c72a..23fbbfd2db 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommand.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommand.cs @@ -303,13 +303,13 @@ namespace ICSharpCode.UnitTesting void RunTests(SelectedTests selectedTests) { if (testProgressMonitor == null) { + OnBeforeRunTests(); testProgressMonitor = context.StatusBarService.CreateProgressMonitor(); totalProjectCount = selectedTests.Projects.Count; } testProgressMonitor.TaskName = GetProgressMonitorLabel(selectedTests.Project); testProgressMonitor.Progress = GetProgress(selectedTests.Projects); - OnBeforeRunTests(); testRunner = CreateTestRunner(selectedTests.Project); if (testRunner != null) { StartTestRunner(); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs index 014d664dd7..4e7f852848 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs @@ -68,5 +68,12 @@ namespace UnitTesting.Tests.Tree runTestCommand.CallTestsCompleted(); Assert.IsFalse(AbstractRunTestCommand.IsRunningTest); } + + [Test] + public void OnBeforeTestRunIsCalledOnlyOnce() + { + int count = runTestCommand.OnBeforeRunTestsMethodCallCount; + Assert.AreEqual(1, count); + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs index 00a0e68b92..bae4e560e7 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs @@ -21,6 +21,7 @@ namespace UnitTesting.Tests.Utils public bool IsRunningTestWhenOnBeforeBuildCalled; public bool IsOnStopMethodCalled; public List TestRunnersCreated = new List(); + public int OnBeforeRunTestsMethodCallCount; public DerivedRunTestCommand(IRunTestCommandContext context) : base(context) @@ -74,5 +75,10 @@ namespace UnitTesting.Tests.Utils { return CreateTestRunner(project); } + + protected override void OnBeforeRunTests() + { + OnBeforeRunTestsMethodCallCount++; + } } }