0

Stryker fails to run any test cases under a xunit test class when debug statement is included in the code block.

I have a few test cases covering the below method. Stryker fails to run those tests and also other tests available for other methods in the same class. I tried using "Stryker disable all" and "Stryker restore all" and it doesn't work.

When debug is removed from the below code block all the test cases are executed and stryker just works fine.

I tried running the tests cases in both debug and release mode. Stryker's behaviour is same.

Stryker command:

dotnet stryker -o 
private async Task<X509Certificate2> getcert(string certname, string password)
{
    #if DEBUG
        return new X509Certificate2(certname,
            password);
    #endif
      
    return await _someprovider.getcert(certname,password);
} 
Florian
  • 1,019
  • 6
  • 22
IamChandu
  • 355
  • 6
  • 18
  • In what way *exactly* is the test failing to run? In your example, if certname is not a file that exists, protected by that password, an exception would be thrown. https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.-ctor?view=net-7.0#system-security-cryptography-x509certificates-x509certificate2-ctor(system-string-system-string) – Jeremy Lakeman Jun 01 '23 at 06:50
  • Tests are executed successfully when executed via xunit/visual studio. I don't get to see actual error from stryker. I see only this message in the terminal Number of tests found: 33 for project 4 tests are failing. Stryker will continue but outcome will be impacted. – IamChandu Jun 01 '23 at 07:09
  • This is weird. I tried putting DEBUG statements in some playground projects and things work as expected. Consider reporting the bug [here](https://github.com/stryker-mutator/stryker-net/issues) with more details: I guess ideally with some tests which are marked as failing. – psfinaki Jun 05 '23 at 11:59

0 Answers0