Skip to content

Commit

Permalink
Implement Reload
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Apr 18, 2019
1 parent fbc0e92 commit 4086630
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
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

0 comments on commit 4086630

Please sign in to comment.