bkaestner / codewars-rules

Arbitrary rules by an arbitrary Codewars warrior. THIS REPOSITORY IS LOOKING FOR A NEW MAINTAINER
https://bkaestner.github.io/codewars-rules/
Other
12 stars 5 forks source link

Outdated C# [TestCase] attribute info #42

Closed PoLaKoSz closed 3 years ago

PoLaKoSz commented 4 years ago

While i was reading this codex i found this section:

Unfortunately, [TestCase] does not report the used parameters on a failed test. An alternative is to use Assert.* with a custom message:

This is no longer the case. Here is a simple demonstration:

Solution:

class A { }

Sample Tests:

using NUnit.Framework;

[TestFixture]
public static class CodexTest 
{
    [TestCase(0)]
    [TestCase(1)]
    public static void TestTestCase(int input)
    {
        Assert.That(0, Is.EqualTo(input));
    }
}

Output:

Test Results:
  CodexTest
    TestTestCase
        TestTestCase(0)
        TestTestCase(1)
            Test Failed
                Expected: 1
                But was:  0
            Completed in 65.5410ms
        Completed in 102.8990ms
    Completed in 108.7030ms
bkaestner commented 4 years ago

Hey @PoLaKoSz, thanks for the heads up. Unfortunately, I'm no longer active on Codewars and don't maintain this document anymore (see #41). But I will happily merge a pull request :)