From 36119d830625dbda30908d7520b7090efdb020ca Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Wed, 8 Apr 2020 08:43:58 -0500 Subject: [PATCH] Example PR with failing tests --- .github/workflows/test.yml | 12 +++++++++++- .gitignore | 6 +++++- UnitTest1.cs | 31 +++++++++++++++++++++++++++++++ nunit-reporter.csproj | 17 +++++++++++++++++ src/nunit.ts | 2 +- 5 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 UnitTest1.cs create mode 100644 nunit-reporter.csproj diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dff717..c25faee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,9 +15,19 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.100' + + - name: Run Tests + run: dotnet test --logger:nunit + - uses: ./ + if: always() with: - path: '*.xml' + path: 'TestResults/*.xml' access-token: ${{secrets.GITHUB_TOKEN}} - name: Publish if: github.event_name == 'push' && github.ref == 'refs/heads/master' diff --git a/.gitignore b/.gitignore index 18e337d..48ce4a4 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,8 @@ Thumbs.db # Ignore built ts files __tests__/runner/* -lib/**/* \ No newline at end of file +lib/**/* + +bin +obj +TestResults \ No newline at end of file diff --git a/UnitTest1.cs b/UnitTest1.cs new file mode 100644 index 0000000..bdc5e3d --- /dev/null +++ b/UnitTest1.cs @@ -0,0 +1,31 @@ +using System; +using NUnit.Framework; + +namespace nunit_reporter +{ + public class Tests + { + [SetUp] + public void Setup() + { + } + + [Test] + public void PassingTest() + { + Assert.Pass(); + } + + [Test] + public void FailingTest() + { + Assert.Fail("This test should fail"); + } + + [Test] + public void TestWithException() + { + throw new InvalidOperationException("Some error happened"); + } + } +} \ No newline at end of file diff --git a/nunit-reporter.csproj b/nunit-reporter.csproj new file mode 100644 index 0000000..b847fcd --- /dev/null +++ b/nunit-reporter.csproj @@ -0,0 +1,17 @@ + + + + netcoreapp3.1 + nunit_reporter + + false + + + + + + + + + + diff --git a/src/nunit.ts b/src/nunit.ts index efcd3b2..80c89fe 100644 --- a/src/nunit.ts +++ b/src/nunit.ts @@ -49,7 +49,7 @@ function getLocation(stacktrace: string): [string, number] { const lineNo = parseInt(match[2]) if (lineNo !== 0) return [match[1], lineNo] } - + return ['unknown', 0] }