From 6d3828b9a94dc26427441491d0a825fb805dac80 Mon Sep 17 00:00:00 2001 From: Rune Soerensen Date: Fri, 13 Dec 2024 03:00:31 -0500 Subject: [PATCH] Add basic dotnet test failure integration test --- buildpacks/dotnet/tests/dotnet_test_test.rs | 19 +++++++++++++++ .../fixtures/xunit_project_fail/FooTests.cs | 10 ++++++++ .../fixtures/xunit_project_fail/foo.csproj | 23 +++++++++++++++++++ .../fixtures/xunit_project_fail/global.json | 6 +++++ 4 files changed, 58 insertions(+) create mode 100644 buildpacks/dotnet/tests/fixtures/xunit_project_fail/FooTests.cs create mode 100644 buildpacks/dotnet/tests/fixtures/xunit_project_fail/foo.csproj create mode 100644 buildpacks/dotnet/tests/fixtures/xunit_project_fail/global.json diff --git a/buildpacks/dotnet/tests/dotnet_test_test.rs b/buildpacks/dotnet/tests/dotnet_test_test.rs index 417cf56..2421fe6 100644 --- a/buildpacks/dotnet/tests/dotnet_test_test.rs +++ b/buildpacks/dotnet/tests/dotnet_test_test.rs @@ -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)"); + }, + ); +} diff --git a/buildpacks/dotnet/tests/fixtures/xunit_project_fail/FooTests.cs b/buildpacks/dotnet/tests/fixtures/xunit_project_fail/FooTests.cs new file mode 100644 index 0000000..01ecdff --- /dev/null +++ b/buildpacks/dotnet/tests/fixtures/xunit_project_fail/FooTests.cs @@ -0,0 +1,10 @@ +namespace foo; + +public class FooTests +{ + [Fact] + public void FooEqualsFoo() + { + Assert.Equal("foo", "bar"); + } +} diff --git a/buildpacks/dotnet/tests/fixtures/xunit_project_fail/foo.csproj b/buildpacks/dotnet/tests/fixtures/xunit_project_fail/foo.csproj new file mode 100644 index 0000000..9c5b30a --- /dev/null +++ b/buildpacks/dotnet/tests/fixtures/xunit_project_fail/foo.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + diff --git a/buildpacks/dotnet/tests/fixtures/xunit_project_fail/global.json b/buildpacks/dotnet/tests/fixtures/xunit_project_fail/global.json new file mode 100644 index 0000000..3040dea --- /dev/null +++ b/buildpacks/dotnet/tests/fixtures/xunit_project_fail/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "8.0.101", + "rollForward": "disable" + } +}