question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test-Run fails with "Internal error due to compile error" on generated code

See original GitHub issue

The generated code for a dto by an OpenApi-generator (“csharp-netcore”) contains the following method:

/// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            yield break;
        }

This results in the following message for every dto in the project when running stryker.net:

Stryker.NET encountered an compile error in <file> with message: Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration. (Source code: return default(
        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult>);)
[06:52:14 WRN] Safe Mode! Stryker will try to continue by rolling back all mutations in method. This should not happen, please report this as an issue on github with the previous error message.

Stopping with

[08:58:44 FTL] Stryker.NET could not compile the project after mutation. This is probably an error for Stryker.NET and not your project. Please report this issue on github with the previous error message.
08:58:44 ERR] An error occurred during the mutation test run 


Internal error due to compile error.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dupdobcommented, May 3, 2021

I don’t think this is related to generated code. There is two issues here:

  1. Stryker injects a return default(type) or yield return default(type) at the end of methods. It should have injected a yield return here. The decision is based on the (pre)existence of a yield return in the code. We did not think about having only yield break.
  2. The rollback mechanism should have removed the injected return default(type) but it clearly failed to do so.

Both should be fixable and will be fixed. Until a fix is available, the best course of action is to ignore this file with Stryker options.

0reactions
pscheichercommented, May 3, 2021

This fix solves my problem. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compile error in test run ends up with "tests passed ...
I sympathize with everyone who wishes that go test had a -json flag. Doesn't go test return a non-zero exit code when compilation...
Read more >
Not able to run Junit test cases in IntelliJ version ...
I have found two links link1 and link2 but not able to resolve the issue. Please help. Error I am getting : Information:java:...
Read more >
.Net Core C# Unit test projects give internal error in ...
Net Core MSTest Unit test project, all variables I try to examine return "Internal Error in the C# compiler". This happens from Immediate ......
Read more >
Troubleshoot code coverage - Visual Studio
Learn how to resolve erroneous empty results messages when you expect Visual Studio to collect data for native and managed assemblies.
Read more >
Performance testing error messages
A Test could not be launched on Driver: %1 due to an internal error. Please see Problem Determination Log. For more information, see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found