Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

399
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda