Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

389
Visualizações
Why does nunit not run a test which contains control/special chars

If I have a test class like

public class Tests
{
    [TestCaseSource(nameof(TestSource))]
    public void Test(string c)
    {
        Assert.Pass();
    }

    public static IEnumerable<object> TestSource()
    {
        for (char c = '\0'; c < 255; c++)
        {
            yield return c.ToString();
        }
    }
}

then the test runner in the Visual Studio can discover all the tests but doesn't run all of them.

these are the ascii character ranges that are not running:

U_0001 - U_0006
U_000E - U_001F
U_007F - U_0084
U_0086 - U_009F

We currently use some of these characters like U_0002 for network work related test which are included in the test but currently do not run

This is the output for the test run

---------- Starting test discovery for requested test run ----------
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery complete
========== Test discovery finished: 255 Tests found in 4,8 sec ==========
---------- Starting test run ----------
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in C:\Users\WEIK014\source\repos\TestSourceTestProject\TestSourceTestProject\bin\Debug\netcoreapp2.1\TestSourceTestProject.dll
   NUnit3TestExecutor discovered 199 of 199 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
========== Test run finished: 199 Tests run in 8,6 sec (199 Passed, 0 Failed, 0 Skipped) ==========

as you see it doesn't even recognize that it skips tests.

Versions in the project:

  • Project .Net Core 2.1
  • NUnit 3.13.1
  • NUnit3TestAdapter 3.17.0

Here is some visual proof that these test do not run enter image description here

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Well that sounds like it's probably a bug somewhere in Visual Studio or the test adapter with displaying Unicode control characters. As a workaround, you can override the test display name for control characters:

public static IEnumerable<TestCaseData> TestSource()
{
    for (char c = '\0'; c < 255; c++)
    {
        var data = new TestCaseData(c.ToString());
        if (char.IsControl(c))
        {
            data.SetArgDisplayNames($"{(int)c:X4}");
        }
        yield return data;
    }
}

This will preserve the display for printable characters (e.g. Test("a")), and the control characters will display as Test(0001), etc.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda