Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconclusive test cases in NUnit theories yield test step failures #162

Open
ghost opened this issue Feb 2, 2022 · 1 comment
Open

Inconclusive test cases in NUnit theories yield test step failures #162

ghost opened this issue Feb 2, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Feb 2, 2022

Bug description

When using NUnit's TheoryAttribute (https://docs.nunit.org/articles/nunit/writing-tests/attributes/theory.html) together with assumptions, it is normal that some test cases of a theory yield an "inconclusive" test result. This is expected, and inconclusive theory results should be filtered out from normal test results, as the NUnit documentation states:

Since the user does not generally care about inconclusive cases under a theory, they are not normally displayed in the Gui. For situations where they are needed - such as debugging - the context menu for the theory provides an option to display them.

However, it seems that Unity returns exit code 2 when having inconclusive tests, and therefore run_tests.sh marks the run illegally as failed, here:

echo "Run succeeded, some tests failed";

Instead, the step should not be marked as failed at this point, since it leads to a workflow failure, but detection of the final result should be deferred to the test evaluation step.

How to reproduce

Set up a test project having at least one NUnit theory test, similar to this:

using NUnit.Framework;

namespace Tests.EditMode {

[TestFixture]
public class ExampleTheory {
    [Theory]
    public void SomeTestTheory([Values(1, 2, 3)] int number) {
        // This will not run the theory for number == 3.
        Assume.That(number != 3);
        // This will assert true, since it only runs for number == 1 and number == 2.
        Assert.Less(number, 3);
    }
}

}

This will create three test cases, two of which run successful, and one which runs without conclusion (so neither success nor failure). While the game.ci test report shows 2 successful tests of a total of 3 tests, and no failure, the test step is marked as failure due to the return code emitted by Unity.

@ghost ghost added the bug Something isn't working label Feb 2, 2022
@webbertakken webbertakken added enhancement New feature or request and removed bug Something isn't working labels Feb 2, 2022
@webbertakken
Copy link
Member

Hi @Moonshinebot. And thanks a lot for the detailed description and clear explanation!

I have marked this issue as an improvement rather than a bug because we're running unity-editor -runTests as per the Unity Editor specification. It is the unity editor itself that returns an erroneous exit code.

That said, I think it's a good idea to implement something in test-runner that will run a check and filter the results like you suggested. We're open to PRs for anyone who'd like to take this on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant