geberit / Revit.TestRunner

Unit Test Runner for Autodesk Revit
MIT License
81 stars 28 forks source link

Unable to find tests in merged assembly. IL-Repack #15

Closed tm-nti closed 2 years ago

tm-nti commented 2 years ago

Hello

We are using IL-Repack to merge our assemblies and a few dependent assemblies together. With the test assembly also added to the merged assembly, Revit TestRunner is unable to find the tests inside it. I do not know how nunit finds the tests but when loading the merged dll, nothing shows up in the treeview. It can find the tests just fine in the unmerged test assembly, but the code loaded into Revit is in the merged dll, so it cannot run

Any help would be greatly appreciated

tobiasfloescher-geberit commented 2 years ago

Hello, I tried briefly to use IL-Repack on SampleTestProject.dll and was able to reproduce the problem. The analysis/explore of the assembly is done by the nUnit framework itself, so I have no idea what the problem could be. I'm sorry. What is the purpose of using IL-Repack for a test setup? I would recommend using a classic test assembly instead.

tobiasfloescher-geberit commented 2 years ago

Message from nUnit: "No suitable tests found in 'C:\temp\ILmerge\test.dll'. Either assembly contains no tests or proper test driver has not been found."

tm-nti commented 2 years ago

Why we use IL-Repack: We have several products that use the same dependencies, but some use different versions. The version loaded into Revit may not be compatible with the version we need, so we merge them all into one assembly, thereby avoiding version juggling and mismatches.

So the methods we wish to test are in the merged assembly, and it is the merged assembly that revit loads in at startup. But our test assembly is looking at the non-merged assembly, which is not loaded into Revit. So they always fail.

I was hoping I could merge the test assembly in as well, since the test methods are marked with the Test attribute, but I do not know how nunit finds the tests, therefore I don't know what the problem is

tobiasfloescher-geberit commented 2 years ago

I'm sorry, I have no idea at the moment either. Maybe it is a problem of IL-Repack?

tm-nti commented 2 years ago

Hello, sorry for the late reply IL-Repack is working fine. I have checked the merged dll using dotpeek, and it contains all the tests in their correct namespaces and attributes. So I don't believe that is the cause, but if it is the nunit framework that looks for the tests, the problem might lie deeper. I suggest we close this issue, and I will look further into nunits handling of "finding" tests

tobiasfloescher-geberit commented 2 years ago

Hi, I did the same with dotpeek, this is why I thought it is a IL-Repack problem. As you proposed, I will close the issue. Good luck and let me know if you found a solution.