-
Notifications
You must be signed in to change notification settings - Fork 106
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
NUnit failed to load .exe with uninformative error message in test discovery #231
Comments
How are you running your tests, VS or the console runner. Are all the projects x86 or x64? What is the unhelpful error, it might mean something to us. Your scenario works, some of our unit tests at work are the same, but the native code forces you to be more correct. |
Hello, thank you for your reply. I try to run it via the VS test runner using the Addin, but detection fails. All projects are x64, also the C# projects are specifically set to x64. Unfortunately "NUnit failed to load $PathToExe" is exactly the only error I get in the output window from the Unit Test Adapter. That is why I called it unhelpful :) |
The specific sequence of messages in the Output Window would tell us whether this occurs in discovery or execution, but given the content it actually doesn't matter. The message is actually very informative. It means that NUnit was instructed to load an assembly named "$PathToExe", and could not do so, which is rather unsurprising. :-) I gather that $PathToExe is the name of some property that you are expecting to be populated with a value, but which is not. |
Ohm, no, its not a property or anything. $PathToExe was simply used by me as a placeholder for a valid path to the compiled .exe of my application.
|
I have categorized this as a question for now. We can change it if we find issues, but I think it is likely a setup problem. |
@rprouse Yes I did. I was falling over that trap with a Boot Test Adapter already :) |
Are you using the NuGet package of NUnit or the MSI install? There is a bug in the MSI install where the 4.5 reference goes to the portable version of the framework which doesn't run under VS. |
@apriori The message you have is a sort of "last resort" message, after a number of things have been checked. It's not worded well, I'm afraid. In fact, the assembly was actually loaded. What failed was loading tests. The assembly loaded and discovery finished without any exceptions being thrown, but the assembly is non-runnable. The code next checks to see if that's because no tests were found. It would display a different message in that case, as it does in the next line of output for a different dll. Finally, it gives up and displays the message you see. It should probably instead check the XML for an embedded message left behind by the framework. If you try running this same assembly as a test under nunit3-console, you may get a better message that will explain things. OTOH, you may not, since nunit3-console will try to run the assembly in an appropriate process, whereas the adapter uses the process given to it by Visual Studio. |
@rprouse I think this is at least a message bug, so I'm going to re-label it. Looking at the code, we actually examine the message in the XML to see if the assembly is non-runnable because it doesn't have tests. However, we never use the message we found and just give this generic message. |
I'm leaving this as both a bug and a question, since we should still try to resolve @apriori 's problem. |
I use the nuget package. Although I had to manually reference the .net 4.5 nunit.framework.dll for the project. Well, using nunit3-console I get a tad bit more useful message:
Sry, I kind of failed trying to set the codepage of cmd to english. This is a typical load error, although "Fixups" abd (IAT/TLS) might give a hint. Full TestResult.xml <?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="2" testcasecount="0" result="Failed" label="Invalid" total="0" passed="0" failed="0" inconclusive="0" skipped="0" asserts="0" engine-version="3.4.1.0" clr-version="4.0.30319.42000" start-time="2016-09-28 16:13:14Z" end-time="2016-09-28 16:13:14Z" duration="0.084194">
<command-line><![CDATA["C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "C:\project\x64\Debug\application.exe" --work=D:]]></command-line>
<test-suite type="Assembly" id="0-1000" name="application.exe" fullname="C:\project\x64\Debug\application.exe" runstate="NotRunnable" testcasecount="0" result="Failed" label="Invalid" site="SetUp" start-time="2016-09-28 16:13:14Z" end-time="2016-09-28 16:13:14Z" duration="0.023630" total="0" passed="0" failed="0" inconclusive="0" skipped="0" asserts="0">
<environment framework-version="3.4.1.0" clr-version="4.0.30319.42000" os-version="Microsoft Windows NT 6.1.7601 Service Pack 1" platform="Win32NT" cwd="C:\" machine-name="SOME-MACHINE" user="Some.User" user-domain="SOME-DOMAIN" culture="de-DE" uiculture="de-DE" os-architecture="x64" />
<settings>
<setting name="WorkDirectory" value="D:" />
<setting name="ImageRuntimeVersion" value="4.0.30319" />
<setting name="ImageRequiresX86" value="False" />
<setting name="ImageRequiresDefaultAppDomainAssemblyResolver" value="False" />
<setting name="NumberOfTestWorkers" value="8" />
</settings>
<properties>
<property name="_SKIPREASON" value="Die Datei oder Assembly "application, Version=1.0.6115.30727, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Es wird versucht, eine nicht überprüfbare ausführbare Datei mit Fixups zu laden (IAT mit mehr als 2 Abschnitten oder ein TLS-Abschnitt). (Ausnahme von HRESULT: 0x80131019)" />
</properties>
<failure>
<message><![CDATA[Die Datei oder Assembly "application, Version=1.0.6115.30727, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Es wird versucht, eine nicht überprüfbare ausführbare Datei mit Fixups zu laden (IAT mit mehr als 2 Abschnitten oder ein TLS-Abschnitt). (Ausnahme von HRESULT: 0x80131019)]]></message>
</failure>
</test-suite>
</test-run> Thank you very much for your help guys. I continue on this tomorrow. |
I have a similar issue. I have a solution with both managed and native projects. NUnit adapter seems to try to load a native DLL and fails whenever I rebuild the project. You can see the solution here: Log4JDash. Error message (Log4JParserC.dll is an unmanaged library):
Visual Studio info:
|
I have the same issue as MaxKot; it's related to #248. The issue is otherwise benign except that the The NUnit runner should somehow detect that a project is a native code project and skip it without emitting an error message, but I don't know if there's an API for that off the top of my head. The built in test discoverer for Visual Studio has the following to say:
So perhaps skipping "assemblies" with I don't have time to experiment with this right now but may take a look at it later this week. |
@anttirt @MaxKot You both seem to have a different problem from that which was originally reported. When I marked this easyfix, hoping somebody would take it on, we had ascertained that the original problem could be resolved by simply giving a better message - the message that was already reported internally in the engine. However, that will not give you guys anything but the same messages you already have. The engine currently has no awareness of C++ assemblies. @ANTIRT 's suggestion seems like a good one. Could you file another issue asking us to check for Framework None? Finding the right place to do that in the engine most likely takes this out of the "easyfix" category for newbies. |
@CharliePoole I filed issue #302. Sorry it took me so long. |
In later versions we display this as Warnings, not errors. |
Extra information:
Visual Studio : 2012 Update 5
The project is using .Net 4.5, NUnit 3.4.1. It is a mixed mode application, using C#, MC++ and C++/CLI. The project in question that is not loaded is 100% MC++.
Do you have any pointers on where to search for the error? Also, let me also suggest to improve the error messages. The mere information that something fails is useless without some extra information.
The text was updated successfully, but these errors were encountered: