-
Notifications
You must be signed in to change notification settings - Fork 152
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
Spurious error is reported for non-test projects when running the solution #1465
Comments
And this is the batch script I use to run the nunit console
|
Here are my further findings. It's not entirely clear what #1182 fixes and what it doesn't. On my side, the nunit console test runner won't crash-- that's great since it's now usable, but will report spurious errors with regards to .net standard 2.x DLLs as per above, even they are not test assemblies, and even I choose to skip them via the You might think that having one or two spurious errors are not big deal. But then, I have 10++ .net standard 2.0 DLLs in my solution, and for that solution, I run it a few times in my nightly builds, each time with a different filtering criteria. So it does clutter up my daily unit test reports. It's a huge eyesore for me to even sift through the reports for actual bugs and errors! It seems that I will need to target it to .net framework or .net core, or both. So currently my workaround is to change in the main csproject file from
To
The alternative is to use nunitprojectloader and setup nunit project ( .nunit file), which I don't prefer due to the reasons that I will have to maintain one extra file. Of course, given a choice I would still prefer to target to PS: is this a bug in vsprojectloader? Should someone move it to there? |
The message refers to The project loader was fixed in it's latest release, 3.9.0, to automatically skip non-test assemblies, so you don't actually need that option on the command line when running the solution. However, you should verify two things:
For NUnit, a test assembly is any assembly, which references the NUnit Framework. It doesn't matter whether it has any tests. If you happen to reference the framework for some other reason, you can use the NonTestAssembly attribute to tell NUnit that the assembly is not intended to be a test assembly. If none of those steps helps, we can keep this as a bug to fix. It will probably turn out to be a bug in the project loader, but it can stay here until I confirm that. My advice in your case would be to stop running the solution file and just run your test assembly on the command-line. If there are multiple builds of the test assembly, just put them all on the command-line. This will serve as a workaround and maybe even as the true solution of your problem. |
@CharliePoole , I can confirm that
And I can really scale down a sample for test. |
@WindingWinter I changed the title to reflect that this issue is not really about .NET Standard 2.0 but about erroneously trying to examine non-test projects when using the VS Project loader extension to run from the solution file. Most likely, this will be a bug in the extension but it could instead be in how the engine interacts with the extension. I'll leave it here until I am sure. You mention above that you have a reduced solution, but I get errors trying to open the zip file. A repro I can use would be very helpful. |
@CharliePoole , I attached a new zip Previously I was zipping it using winrar, which is why you couldn't open it . Now you should be able to open it either way. |
@WindingWinter Thanks. I can open that one on pop-os and also on my windows vm. I'll try to see first if this is actually a bug in the vs project loader, which should be skipping the non-test file automatically. |
I have added tests using VS Project loader 3.9.0 to the console runner's package tests. They confirm that the project loader is operating as designed. After the Note that the non-test projects are not simply dropped. They are still included as subpackages but the
Obviously an assembly requires a certain degree of analysis in order to determine that it's a non-test assembly. The exception we are seeing seems to indicate that certain checks are being made too early. That is, the engine should do what is needed to identify non-test projects first, before continuing with any deeper analysis. For example, we may not need to know the target runtime in order to ensure that we have a test project. This is easy to state as a strategy but may be harder to implement. I'll take it one step at a time. |
@WindingWinter Could issue nunit/vs-project-loader#67 be affecting you? I worked around it in one of my own projects by duplicating elements in the project itself. |
@CharliePoole , it's not entirely clear to me how that nunit/vs-project-loader#67 affects anything ( I don't know nearly enough about the internal of nunit console or vs project loader to say). The way I workaround the issue is that instead of using .net standard 2.0 as my target framework, I multi target the assembly to .net48 and .net80. |
@WindingWinter No need to understand internals. It's just a question of whether you use a |
@CharliePoole , this I can answer. The answer is no I don't use |
Good. That's one less thing to worry about. :-) |
I have replicated the problem with .NET Standard 2.0. The check and resulting exception are apparently made too early, before we have determined it's a non-test assembly. |
@WindingWinter This fix is available from myget either as a nuget package or a chococolatey package. Please try it and let me know how it works for you. You might also try that build for the problem in #1468. I'm doubtful, but there are substantial changes that could change the error even if it doesn't fix it. |
This issue has been resolved in version 3.18.2 The release is available on: |
@CharliePoole , I've downloaded and tried 3.18.2. And this problem is still reproducible. Other issues like #1468 and #1469 seems to be solved. |
@WindingWinter I don't get it. I'm loading and running a solution with a netstandard project in my tests. Would you take a look at solution TestData.sln in the repository and see if you can determine how it is different from your own example? |
From your example here,
Seems to work, but on my side, both plural and singular
and
don't work and will have the original error. Do you think an attached zip example will help? |
Oh well, I can reproduce the problem with the zip file attached here. Exactly the same error. Here's the batch file if you are interested:
|
Is it possible the timeout issue is affecting you in this one as well? If not, I'll download your entire solution and try that. For the release, I used it as a model but didn't use the whole thing. |
No, nothing to do with the timeout. As you can see from the batch script in
my previous reply
…On Fri, Sep 20, 2024, 9:43 PM CharliePoole ***@***.***> wrote:
Reopened #1465 <#1465>.
—
Reply to this email directly, view it on GitHub
<#1465 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADENIZUG3NQAGN5AMJMLJ4DZXQRAPAVCNFSM6AAAAABNLV5PN2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGM2DANJSGMYDAOA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Example code is passing using the latest dev build (3.18.3-dev00009 +) from MyGet. No exception, two failures, one pass. |
I'm also getting the same error with 3.18.2 & 3.18.3, when trying to test a net48 WPF application that references a netstandard2.0 library, which has it's own test project in net8, even when the test count is 0 due to filters and the --skipnontestassemblies flag.
It does however work as expected on our old buildserver which uses the version 3.16.3, where it just outputs a warning as the overall result and no errors. |
Referring to #1182. I have problem when I run tests using nunit console 3.18: spurious error is report for main project that targets .NET Standard 2.0
A description of my solution file: it consists of a .net standard 2.0 library, and a test library that consumes the main library. The test library is targeted to .net framework 4.8.
I download the nunit console 3.18. from here. And I run the
nunit-console.exe
frombin\net462
folder. When I run the nunit console, this is the output that I get:I can run the test library that consumes .net standard 2.0 code; as you can see above, the correct number of tests (3) are run and reported.
However, somehow the presence of NetStandard20Lib library is reported as an additional error
Which is completely spurious. The
NetStandard20Lib.dll
is the main library targetting .net standard 2.0. It is not supposed to be under testing. No idea why it is there at all.I can confirm that running the nunit console in the nuget folder will also give me exactly the same error.
The text was updated successfully, but these errors were encountered: