Skip to content

Commit

Permalink
Merge pull request #79 Add a global setup when using a --test= option
Browse files Browse the repository at this point in the history
Add a global setup when using a --test= option
  • Loading branch information
Kevin Willford authored Aug 21, 2019
2 parents 36e85ec + 857280a commit c6ec165
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Scalar.FunctionalTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void Main(string[] args)
{
Properties.Settings.Default.Initialize();
NUnitRunner runner = new NUnitRunner(args);
runner.AddGlobalSetupIfNeeded("Scalar.FunctionalTests.GlobalSetup");

if (runner.HasCustomArg("--no-shared-scalar-cache"))
{
Expand Down
9 changes: 9 additions & 0 deletions Scalar.Tests/NUnitRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public bool HasCustomArg(string arg)
return this.args.Remove(arg);
}

public void AddGlobalSetupIfNeeded(string globalSetup)
{
// If there are any test filters, the GlobalSetup still needs to run so add it.
if (this.args.Any(x => x.StartsWith("--test=")))
{
this.args.Add($"--test={globalSetup}");
}
}

public int RunTests(ICollection<string> includeCategories, ICollection<string> excludeCategories)
{
string filters = GetFiltersArgument(includeCategories, excludeCategories);
Expand Down
1 change: 1 addition & 0 deletions Scalar.UnitTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Program
public static void Main(string[] args)
{
NUnitRunner runner = new NUnitRunner(args);
runner.AddGlobalSetupIfNeeded("Scalar.UnitTests.Setup");

List<string> excludeCategories = new List<string>();

Expand Down

0 comments on commit c6ec165

Please sign in to comment.