Skip to content

Commit

Permalink
nunit#1 Handling of TeamCity messages is different between the engine…
Browse files Browse the repository at this point in the history
… and nunitlite - add tests for nunitlite
  • Loading branch information
Nikolay Pianikov authored and Nikolay Pianikov committed Aug 2, 2016
1 parent 773b4a3 commit e9ea151
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Task("InitializeForIntegrationTests")
CleanDirectories(TEST_NUNIT_DIR + "**/*.*");
CleanDirectories(TEST_PACKAGES_DIR + "**/*.*");
NuGetInstall(new [] {"NUnit.Runners", "NUnit"}, new NuGetInstallSettings()
NuGetInstall(new [] {"NUnit.Runners", "NUnit", "NUnitLite"}, new NuGetInstallSettings()
{
OutputDirectory = TEST_NUNIT_DIR,
Source = PRERELEASE_PACKAGE_SOURCE,
Expand Down
10 changes: 9 additions & 1 deletion src/nunit.integration.tests/Dsl/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ public void Compile(TestAssembly testAssembly, string assemblyFileName, TargetDo
break;
}

var outputKind = OutputKind.DynamicallyLinkedLibrary;
switch (Path.GetExtension(assemblyFileName)?.ToLowerInvariant())
{
case ".exe":
outputKind = OutputKind.ConsoleApplication;
break;
}

var assemblyInfoSyntaxTree = CSharpSyntaxTree.ParseText(ResourceManager.GetContentFromResource(AssemblyInfoResourceName) + Environment.NewLine + string.Join(Environment.NewLine, testAssembly.Attributes));
var compilation =
CSharpCompilation.Create(Path.GetFileName(assemblyFileName))
.WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
.WithOptions(new CSharpCompilationOptions(outputKind)
.WithPlatform(testAssembly.Platform)
.WithOptimizationLevel(OptimizationLevel.Debug))
.AddReferences(GetDotNetFrameworkReferences(dotNetFrameworkVersion, architecture))
Expand Down
1 change: 1 addition & 0 deletions src/nunit.integration.tests/Dsl/EnvironmentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void CopyReference(string directoryName, string referenceFileName)
public IEnumerable<string> EnumerateNUnitAssemblies(string nunitBasePath, TargetDotNetFrameworkVersion frameworkVersion)
{
yield return GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "nunit.framework.dll");
yield return GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "nunitlite.dll");
var file = GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "NUnit.System.Linq.dll");
if (file != null)
{
Expand Down
10 changes: 10 additions & 0 deletions src/nunit.integration.tests/NUnitSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ public void RunNUnitConsole()
ctx.TestSession = testSession;
}

[When(@"I run (.+)")]
public void Run(string executable)
{
var ctx = ScenarioContext.Current.GetTestContext();
var runner = new NUnitRunner();
ICommandLineSetupFactory setupFactory = new GenericCommandLineSetupFactory(executable);
var testSession = runner.Run(ctx, setupFactory.Create(ctx));
ctx.TestSession = testSession;
}

[Then(@"processes (.+) are finished")]
public void CheckProcessesWereFinished(string processName)
{
Expand Down
5 changes: 5 additions & 0 deletions src/nunit.integration.tests/Templates/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
[TestFixture]
internal class UnitTest
{
public static int NUnitLiteEntryPoint(string[] args)
{
return new NUnitLite.AutoRun(typeof(Program).Assembly).Execute(args, new NUnit.Common.ExtendedTextWrapper(Console.Out), Console.In);
}

[SetUp]
public void FailedSeTup()
{
Expand Down
10 changes: 10 additions & 0 deletions src/nunit.integration.tests/nunit.integration.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
</Choose>
<ItemGroup>
<Compile Include="CommonSteps.cs" />
<Compile Include="Dsl\GenericCommandLineSetupFactory.cs" />
<Compile Include="Dsl\ArgumentsCommandLineSetupFactory.cs" />
<Compile Include="Dsl\CommandLineArtifact.cs" />
<Compile Include="Dsl\CommandLineSetup.cs" />
Expand Down Expand Up @@ -254,6 +255,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>SupportPlatforms.feature</DependentUpon>
</Compile>
<Compile Include="TeamCityForNUnitlite.feature.cs">
<DependentUpon>TeamCityForNUnitlite.feature</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="TeamCity.feature.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -294,6 +300,10 @@
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>SupportPlatforms.feature.cs</LastGenOutput>
</None>
<None Include="TeamCityForNUnitlite.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>TeamCityForNUnitlite.feature.cs</LastGenOutput>
</None>
<None Include="TeamCity.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>TeamCity.feature.cs</LastGenOutput>
Expand Down

0 comments on commit e9ea151

Please sign in to comment.