Search code examples
.netnunitnunit-console

Nunit-console3 default encoding


I'm saving failed tests to file to rerun them again with nunit-console3. Looks like some tests which contains TestCase with Cyrillic characters in test case parameters are skipped. I looked at file and seams that encoding is quite strange. What is default --encoding=... parameter for nunit-console3?

I don't see this in documentation, maybe someone will know it.


Solution

  • Default behaviour is to use the system default, the encoding is only changed if specifically specified via a command line flag.

    See the source code, here: https://github.com/nunit/nunit-console/blob/91ef2ae1b1077ad450d27667c6c4b3ec84b8cdf5/src/NUnitConsole/nunit3-console/Program.cs#L68

            if (!string.IsNullOrEmpty(Options.ConsoleEncoding))
            {
                try
                {
                    Console.OutputEncoding = Encoding.GetEncoding(Options.ConsoleEncoding);
                }
                catch (Exception error)
                {
                    WriteHeader();
                    OutWriter.WriteLine(ColorStyle.Error, string.Format("Unsupported Encoding, {0}", error.Message));
                    return ConsoleRunner.INVALID_ARG;
                }
            }