TestCentric / testcentric-engine

Test engine that loads and runs tests for TestCentric
MIT License
0 stars 3 forks source link

.NET Core agents don't set AppDomain.CurrentDomain.BaseDirectory as expected #76

Closed CharliePoole closed 1 year ago

CharliePoole commented 1 year ago

This issue reflects issue nunit/nunit-console#1313. We anticipate that the same problem exists in the TestCentric engine since it contains similar code to the NUnit engine and runs .NET Core tests in the agent's primary AppDomain.

As I commented on the nunit issue, "NUnit traditionally ran tests in a separate AppDomain, which it created. The .NET Framework agents still do that. You can find the key code in the DomainManager class. That class is only built for .NET Framework. The .NET Core agents all run tests in the primary AppDomain."

The TestCentric agent is currently set up the same way, so I believe the same issue applies. However, it will require confirmation before proceeding.

CharliePoole commented 1 year ago

As expected, this problem is also present in the TestCentric engine.

CharliePoole commented 1 year ago

I've done a bit of reading and I'm now doubtful that behavior I confirmed is actually a bug, so I'm flagging this as needing discussion before any more is done. My reasoning is as follows..

  1. AppDomains are somewhat minimally supported in .NET Core. In particular, they cannot be created.
  2. As a result, all code runs in the primary AppDomain of the process hosting it.
  3. Consequently, no test assembly being executed by a test runner should expect the ApplicationBase to be anything other than the primary AppDomain.
  4. In addition, any assembly referenced by the test assembly will also be a .NET Core or Standard assembly, so the same limitations apply to it.

That said, there could be use cases I don't know about that violate these assumptions. If so, I'd like to hear about them.

CharliePoole commented 1 year ago

There has been no further comment on this for more than two months. Closing.