jcansdale / TestDriven.Net-Issues

Issue tracking for TestDriven.Net
https://github.com/jcansdale/TestDriven.Net-Issues/issues
24 stars 2 forks source link

Force English output #146

Open sm-g opened 5 years ago

sm-g commented 5 years ago

For non-english Windows exceptions during tests written in console in local language. As result, VisualStudio's "find message in code" feature not working (cannot just click on exception to go to sources).

There is workaround for me as user - tweak ProcessInvocation.exe.config/ProcessInvocation86.exe.config inside one of AppData\Local\Microsoft\VisualStudio\15.0_82d42fe1\Extensions folders.

Setting Thread.Current(UI)Culture to InvariantCulture should help.

Maybe it should be optional.

jcansdale commented 5 years ago

Sorry I missed this issue. What language are you using? Could you send me a sample stack trace?

I do have workarounds in place for a few languages. I'm happy you add yours as well!

sm-g commented 5 years ago

I'm using ru-RU. Stack trace:

System.NotImplementedException: Метод или операция не реализована.
   в My.Application.Services.ImportActionsService.<InitializeImplementation>d__10.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
jcansdale commented 5 years ago

That's strange, I thought I'd added support for Russian. 😕

Could I see a stack trace with line numbers as well? I can't see any on that one.

sm-g commented 5 years ago
------ Test started: Assembly: My.Common.Tests.dll ------

Test 'My.Common.EnumerationTests.FromValue_ReturnsFirstOfItemsWithThisValue' failed:   Expected: 0
  But was:  1
       в My.Common.EnumerationTests.FromValue_ReturnsFirstOfItemsWithThisValue() в C:\x\test\My.Common.Tests\EnumerationTests.cs:строка 26

0 passed, 1 failed, 0 skipped, took 1,08 seconds (NUnit 3.11.0).
jcansdale commented 5 years ago

@sm-g,

I was wondering if there are any tricks I should know about using Cyrillic text in C# source?

image

System.ArgumentException : parsing "^(\s*(à|at|à|bei|ved|?)) (?<methodName>[^\\]+)$" - Quantifier {x,y} following nothing.
   at System.Text.RegularExpressions.RegexParser.ScanRegex()
   at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)

I've tried this before and struggled to make it work. The text appears fine in Visual Studio but breaks when I try to create a Regex or output it. 😕

jcansdale commented 5 years ago

I think this might be the trick. 🤞

image

jcansdale commented 5 years ago

@sm-g,

Could you give this version a try and let me know if it works? With any luck it will now recognize Russian/Cyrillic stack frames.

TestDriven.VSPackage-5.0.18092.zip

sm-g commented 5 years ago

@jcansdale Not as expected:

Test 'TDDKata.CalculatorTests.Add_OneNumber_ShouldReturnThatNumber' failed: System.Exception : Выдано исключение типа "System.Exception".
    CalculatorTests.cs(21,0): at TDDKata.CalculatorTests.Add_OneNumber_ShouldReturnThatNumber()

With my solution I have Exception of type 'System.Exception' was thrown.

added support for Russian

Why you need to support each lang individually? Changing thread culture does not work?

jcansdale commented 5 years ago

@sm-g,

Are you able to double click on the following line?

CalculatorTests.cs(21,0): at TDDKata.CalculatorTests.Add_OneNumber_ShouldReturnThatNumber()

Why you need to support each lang individually? Changing thread culture does not work?

I'm reluctant to change the thread culture explicitly as this could change whether some tests pass or fail for some people.

Do you get different results when running NUnit/xUnit from the command line?

Would setting the culture like this be an option?

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  [Culture("fr-FR")]
  public class FrenchCultureTests
  {
    // ...
  }
}
sm-g commented 5 years ago

Yes, double click works. But I want also all exceptions to be not localized.

Thread culture could be an option, so only people who explicitly set it could have changes.

Sorry, but I have no time to check your other questions.