-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34a4dc1
commit e00a6c2
Showing
14 changed files
with
515 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt | ||
|
||
namespace NUnit.Agents | ||
{ | ||
public class DirectTestAgent : NUnitAgent<DirectTestAgent> | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Execute(args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>NUnit.Agents.Agents</RootNamespace> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net462;net8.0</TargetFrameworks> | ||
<OutputPath>..\..\bin\$(Configuration)\direct-test-agent\</OutputPath> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<CheckEolTargetFramework>false</CheckEolTargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\NUnitEngine\nunit.engine.api\nunit.engine.api.csproj" /> | ||
<ProjectReference Include="..\nunit.agent.core\nunit.agent.core.csproj" /> | ||
<ProjectReference Include="..\nunit.extensibility\nunit.extensibility.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'"> | ||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
56 changes: 56 additions & 0 deletions
56
src/NUnitCommon/nunit.agent.core.tests/AgentDirectRunnerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using NUnit.TestData.Assemblies; | ||
|
||
namespace NUnit.Agents | ||
{ | ||
public class AgentDirectRunnerTests | ||
{ | ||
[Test] | ||
public void RunAgentDirectly() | ||
{ | ||
RunTestUnderTestBed(typeof(MockAssembly).Assembly.Location); | ||
} | ||
|
||
private void RunTestUnderTestBed(string testAssembly) | ||
{ | ||
string agentAssembly = typeof(DirectTestAgent).Assembly.Location; | ||
|
||
#if NETFRAMEWORK | ||
string agentExe = agentAssembly; | ||
#else | ||
string agentExe = Path.ChangeExtension(agentAssembly, ".exe"); | ||
#endif | ||
|
||
var startInfo = new ProcessStartInfo(agentExe); | ||
startInfo.Arguments = testAssembly; | ||
startInfo.RedirectStandardOutput = true; | ||
startInfo.UseShellExecute = false; | ||
|
||
Process? process = Process.Start(startInfo); | ||
|
||
if (process != null) | ||
{ | ||
process.WaitForExit(); | ||
|
||
string output = process.StandardOutput.ReadToEnd(); | ||
int index = output.IndexOf("Test Run Summary"); | ||
if (index > 0) | ||
output = output.Substring(index); | ||
|
||
Console.WriteLine(output); | ||
Console.WriteLine($"Agent process exited with rc={process.ExitCode}"); | ||
|
||
if (index < 0) | ||
Assert.Fail("No Summary Report found"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<appSettings> | ||
<add key="test.setting" value="54321"/> | ||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt | ||
|
||
using System.Reflection; | ||
using NUnitLite; | ||
|
||
namespace NUnit.Engine.Tests | ||
{ | ||
class Program | ||
{ | ||
static int Main(string[] args) | ||
{ | ||
return new TextRunner(typeof(Program).Assembly).Execute(args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<appSettings> | ||
<add key="test.setting" value="Alternate config used"/> | ||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.