Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement Reload in the engine #610

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,36 @@ public void Run()
CheckTestRunEvents();
}

[Test]
public void RunAfterReload()
{
// Engine issue #609
_runner.Load();
_runner.Reload();
var result = _runner.Run(this, TestFilter.Empty);

Assert.That(result.Name, Is.EqualTo("test-run"));
CheckTestRunResult(result, _testRunData);

CheckThatIdsAreUnique(result);

CheckTestRunEvents();
}

[Test]
public void ExploreAfterReload()
{
// Engine issue #609
_runner.Load();
_runner.Reload();
var result = _runner.Explore(TestFilter.Empty);

Assert.That(result.Name, Is.EqualTo("test-run"));
CheckResult(result, _testRunData);

CheckThatIdsAreUnique(result);
}

#if !NETCOREAPP1_1
[Test]
public void RunAsync()
Expand Down
8 changes: 2 additions & 6 deletions src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,10 @@ public bool IsPackageLoaded
protected abstract TestEngineResult LoadPackage();

/// <summary>
/// Reload the currently loaded test package. Overridden
/// in derived classes to take any additional action.
/// Reload the currently loaded test package.
/// </summary>
/// <returns>A TestEngineResult.</returns>
protected virtual TestEngineResult ReloadPackage()
{
return LoadPackage();
}
protected abstract TestEngineResult ReloadPackage();

/// <summary>
/// Unload any loaded TestPackage. Overridden in
Expand Down
14 changes: 14 additions & 0 deletions src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ protected override TestEngineResult LoadPackage()
return ResultHelper.Merge(results);
}

/// <summary>
/// Reload the currently loaded test package.
/// </summary>
/// <returns>A TestEngineResult.</returns>
protected override TestEngineResult ReloadPackage()
{
var results = new List<TestEngineResult>();

foreach (var runner in Runners)
results.Add(runner.Reload());

return ResultHelper.Merge(results);
}

/// <summary>
/// Unload any loaded TestPackages.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ protected override TestEngineResult LoadPackage()
return result;
}

protected override TestEngineResult ReloadPackage()
{
var result = new TestEngineResult();
var packages = TestPackage.Select(p => !p.HasSubPackages());

int index = 0;
foreach (IFrameworkDriver driver in _drivers)
{
var package = packages[index++];
result.Add(driver.Load(package.FullName, package.Settings));
}

return result;
}

private static string LoadDriver(IFrameworkDriver driver, string testFile, TestPackage subPackage)
{
try
Expand Down
11 changes: 11 additions & 0 deletions src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ protected override TestEngineResult LoadPackage()
}
}

/// <summary>
/// Reload the currently loaded test package.
/// </summary>
/// <returns>A TestEngineResult.</returns>
protected override TestEngineResult ReloadPackage()
{
log.Info("Reloading " + TestPackage.Name);

return _remoteRunner.Reload();
}

/// <summary>
/// Unload any loaded TestPackage and clear
/// the reference to the remote runner.
Expand Down