Skip to content

Commit

Permalink
Add basic dotnet test failure integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
runesoerensen committed Dec 13, 2024
1 parent be0fc7a commit 6d3828b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
19 changes: 19 additions & 0 deletions buildpacks/dotnet/tests/dotnet_test_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,22 @@ fn test_dotnet_test_success() {
},
);
}

#[test]
#[ignore = "integration test"]
fn test_dotnet_test_failure() {
TestRunner::default().build(
default_build_config("tests/fixtures/xunit_project_fail")
.env("DOTNET_SDK_COMMAND", "test")
.expected_pack_result(libcnb_test::PackResult::Failure),
|context| {
assert_contains!(
context.pack_stdout,
"- Detected .NET file to test: `/workspace/foo.csproj`"
);
assert_contains!(
context.pack_stdout,
"Failed! - Failed: 1, Passed: 0, Skipped: 0, Total: 1, Duration: < 1 ms - foo.dll (net8.0)");
},
);
}
10 changes: 10 additions & 0 deletions buildpacks/dotnet/tests/fixtures/xunit_project_fail/FooTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace foo;

public class FooTests
{
[Fact]
public void FooEqualsFoo()
{
Assert.Equal("foo", "bar");
}
}
23 changes: 23 additions & 0 deletions buildpacks/dotnet/tests/fixtures/xunit_project_fail/foo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "8.0.101",
"rollForward": "disable"
}
}

0 comments on commit 6d3828b

Please sign in to comment.