Closed maettu-this closed 2 months ago
@maettu-this What version of nunit-project-loader are you using?
@maettu-this What version of nunit-project-loader are you using?
3.7.1
Strange! The properties dialog shows the correct location for the dll and the package settings are correct. Yet it cannot be loaded!
OK, this was a bit obscure but makes sense now...
You can use your project from a subdirectory with the following changes:
<NUnitProject>
<Settings activeconfig="Debug" appbase=".." />
<Config name="Debug" binpathtype="Auto">
<assembly path="TestLib\bin\Debug\TestLib.dll" />
<assembly path="TestMain\bin\Debug\TestMain.dll" />
</Config>
</NUnitProject>
It turned out it was failing because it couldn't find the nunit.framework assembly, even though it was in the same directory as the test lib. .NET 4.x looks for dependencies in the appbase and the probing path. The appbase, in this case is the location of the .nunit
file. The probing path directories (called binpath in the project settings) must be under the appbase and that was not the case here. I changed it to specify ..
as the appbase and modified paths accordingly.
The use of binpathtype="Auto" tells the project loader "You figure it out" but that wasn't possible since the referenced assemblies were not under the appbase. This is explained fairly well here: https://docs.nunit.org/articles/nunit/technical-notes/usage/NUnit-Project-XML-Format.html
I understand. While https://docs.nunit.org/articles/nunit/technical-notes/usage/NUnit-Project-XML-Format.html indeed documents this, I neither find the behavior obvious nor convenient.
Could there be a way to automatically determine the appbase? E.g. if all paths are ..\TestXY
the NUnit project loader could figure out the appbase probably is ..
. But not knowing the details behind, I don't know whether there is any way to make this more convenient.
And just for curiosity, would such feature had to be requested at https://github.com/nunit/nunit-project-loader or is it rather the way TestCentric interprets the data provided by the project loader?
@maettu-this
The appbase has long been documented to be the location of the project file, with any relative paths taken relative to that location. The format is too old for a breaking change like that.
The real issue is the probing path. As you may know, .NET follows some simple rules for looking in other directories. I wrote the code we use to figure it out automatically based on the assembly paths in a config but it was almost 20 years ago and I can't remember it very well. I think I looked at the common partial path containing all assemblies, which doesn't work for your example.
The loader gives testcentric info in the package. TC gives .NET info from the package. .NET does the loading. For it to work any other way would be a complete change of architecture, so not likely unless we write a new framework and runner. One possible mitigation would be to give a warning or error when a path contains ..
. That's legal if the assembly has no dependencies in the directory, but it might save trouble to advise against it.
Having TC giving a comprehensive warning sounds like a good approach.
Describe the bug Loading tests of an .nunit project file containing child relative paths works fine. Loading tests of an .nunit project file containing parent relative path fails.
To Reproduce Steps to reproduce the behavior:
ProjectWithChildRelativePathsWorksFine.Debug.nunit
and run all tests -> works fineTestMain\ProjectWithParentRelativePathFailsToLoad.Debug.nunit
-> fails to load testsIssue1077.zip
Expected behavior Parent relative paths shall be properly resolved by TestCentric (if that is the culprit) or NUnit (if that is the culprit),
TestMain\ProjectWithParentRelativePathFailsToLoad.Debug.nunit
shall work fine as well.Screenshots
![grafik](https://github.com/TestCentric/testcentric-gui/assets/24897735/33be3e8f-a5d1-4667-b96a-e61b4cd6f76c)
Environment: