Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated execution of tests for different language versions #3493

Open
bjornhellander opened this issue Apr 24, 2022 · 3 comments
Open

Repeated execution of tests for different language versions #3493

bjornhellander opened this issue Apr 24, 2022 · 3 comments

Comments

@bjornhellander
Copy link
Contributor

A question about the test class inheritance that goes on between the version specific test projects:
I might be missing something, but it looks like most earlier tests are executed for later language versions as well, but without any change in the test setup. (I see that some tests actually change language version in test sub classes, but it does not seem to be very common.)

Two strategies seem reasonable two me:

  1. Executing tests only for the minimum required language version, i.e. the version where the the tested feature was introduced.
  2. Executing all tests for all possible language versions.

What I think is happening now is that tests are re-executed in test projects for higher language versions, but still configured with the same language version as in the test project it was inherited from. So they are executed multiple times with exactly the same setup.

Is this intentional?
Or am I just dead wrong? 😁

Asking since its starting to take quite a while to run the tests.

@sharwell
Copy link
Member

Is this intentional?

Yes, it helps make sure the behavior is consistent across different versions of Roslyn (sometimes behavior changes in Roslyn require workarounds to handle both situations).

@sharwell
Copy link
Member

What I think is happening now is that tests are re-executed in test projects for higher language versions, but still configured with the same language version as in the test project it was inherited from.

Not entirely sure on this one. Would need to check, but I think the default comes from the test project being run, and not the project a test is originally defined in. There are exceptions in cases where an individual test explicitly specifies a language version.

@bjornhellander
Copy link
Contributor Author

After looking more at this, you are of course correct. Since the test projects for later c# versions reference later Roslyn versions,
they will override whatever Roslyn version was referenced from earlier test projects when inheriting test cases. Each Roslyn version has a default language version, which is the one that will be used in all test cases which do not explicitly say otherwise,
so the expected version will typically be used. Good.

But there are quite a few tests that do set the language version explicitly, for example most tests in the c# 8, 9 and 10 test projects. Should these be changed, so we get the behaviour that you described? That test projects for later language versions inherit earlier test cases, but run them with there own language version instead. I have started removing explicit language versions and have not seen any problems so far.

bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue May 12, 2022
…0, so that they will be run with the expected (later) language version in later test projects

DotNetAnalyzers#3493
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue May 12, 2022
…, so that they will be run with the expected (later) language version in later test projects

DotNetAnalyzers#3493
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue May 12, 2022
…, so that they will be run with the expected (later) language version in later test projects

DotNetAnalyzers#3493
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue Jun 19, 2022
…10. Previously, affected tests were always run with the specified language version, even in test projects for later language versions.

DotNetAnalyzers#3493
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue Mar 12, 2023
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue Mar 12, 2023
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue Mar 18, 2023
bjornhellander added a commit to bjornhellander/StyleCopAnalyzers that referenced this issue Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants