GithubHelp home page GithubHelp logo

Comments (11)

eleshoe avatar eleshoe commented on June 2, 2024 1

@Evangelink
Thanks for the clarification, it is clear now.
Thank you very much.

from testfx.

eleshoe avatar eleshoe commented on June 2, 2024

The above github repo url is not working, please use this
DemoUnitTestProject

from testfx.

eleshoe avatar eleshoe commented on June 2, 2024

I also tried to use absolute path to the dependencies in the .runsettings file, but still the same issue as above.

from testfx.

Evangelink avatar Evangelink commented on June 2, 2024

Hi @eleshoe,

Thanks for the detailed issue!

Looking at your project configuration, I think I have found the issue and it seems to be more of a general configuration issue that something specifically related to MSTest. On your tests, you are changing the output path property to ..\unittest and you have the project references DemoProject.csproj and DemoTestBase.csproj setup with <Private>false</Private> which means that you are preventing any local copy of these dlls.

After the compilation, if you open the unittest folder you will see that it contains DemoUnitTestProject.dll but not DemoProject.dll nor DemoTestBase.dll and so when you are executing the tests you end up with the file not found issue.

If you either allow local copy (remove the <Private> parts) or also copy the dll in your output, you will see that the issue is gone and the tests are run properly.

Regarding why the test from the class inheriting TestBase are not found. This is the same issue, because the base class is not found there is a runtime error thrown and so we are unable to discover the test correctly.

I will move forward by closing this issue but feel free to ask for more details if needed.

from testfx.

eleshoe avatar eleshoe commented on June 2, 2024

@Evangelink
Hi, thanks for the quick response.
I understand what you mean, but for net framework 4.7.2, it works, just the net6 not working. Why?

from testfx.

Evangelink avatar Evangelink commented on June 2, 2024

Oh sorry! I went too fast in doing my analysis. I will reopen and investigate the change (I would guess that something is wrong in non-netfx and the AssemblyResolution setting is being ignored.

from testfx.

Evangelink avatar Evangelink commented on June 2, 2024

I was able to investigate the difference. The AssemblyResolve settings is only impacting .NET Framework as some of the custom resolver tools are not available in "core" version of .NET. I think we could improve user experience by printing some warning if we find this property on non-netfx run. We should also update the documentation around this property to specify it's not used in non netfx versions.

from testfx.

eleshoe avatar eleshoe commented on June 2, 2024

I was able to investigate the difference. The AssemblyResolve settings is only impacting .NET Framework as some of the custom resolver tools are not available in "core" version of .NET. I think we could improve user experience by printing some warning if we find this property on non-netfx run. We should also update the documentation around this property to specify it's not used in non netfx versions.

@Evangelink
AssemblyResolve you mean AssemblyResolution?

If I understand correctly, you mean the AssembyResolution is currently not working in .Net 6 (or other "core") and only work in .Net framework; and the solution here is to provide some warnings and update of documentations?

  1. Does that means there will not be any fixing for .Net 6 (or other "core") to be able to use the AssembyResolution?
  2. If there is no fix to use AssembyResolution for .Net 6, what's the alternatives/workaround?

from testfx.

Evangelink avatar Evangelink commented on June 2, 2024

Hi @eleshoe,

My bad, reading again my sentence, I see it's not super clear.

Let me start again. As you pointed out, you are using the AssemblyResolution configuration in the runsettings file. This property allows users to give different locations in which MSTest should try to be loading dlls from. This is used internally in a custom assembly resolver along with AppDomains.

In netcore/net versions of .NET, some functionnalities of the AppDomain are no longer available which is preventing some of the behaviours of MSTest.

To answer more specifically your questions. No, there will not be any "fix" for supporting the AssemblyResolution property in netcore/net versions of MSTest. But we will update the documentation to specify this is not supported AND we will emit a warning if we detect this property in some netcore run.

As for workarounds, I would suggest "fixing" the project setup so that the dlls are found in the location of the test dll. As explained in some previous comment, you could remove the <Private>, you could add a task to copy the dlls in the custom location or edit the "production" projects to emit in the custom location:

Looking at your project configuration, I think I have found the issue and it seems to be more of a general configuration issue that something specifically related to MSTest. On your tests, you are changing the output path property to ..\unittest and you have the project references DemoProject.csproj and DemoTestBase.csproj setup with <Private>false</Private> which means that you are preventing any local copy of these dlls.

After the compilation, if you open the unittest folder you will see that it contains DemoUnitTestProject.dll but not DemoProject.dll nor DemoTestBase.dll and so when you are executing the tests you end up with the file not found issue.

If you either allow local copy (remove the <Private> parts) or also copy the dll in your output, you will see that the issue is gone and the tests are run properly.

Regarding why the test from the class inheriting TestBase are not found. This is the same issue, because the base class is not found there is a runtime error thrown and so we are unable to discover the test correctly.

from testfx.

Evangelink avatar Evangelink commented on June 2, 2024

Warning was not added, reopening

from testfx.

fx999dev avatar fx999dev commented on June 2, 2024

To answer more specifically your questions. No, there will not be any "fix" for supporting the AssemblyResolution property in netcore/net versions of MSTest. But we will update the documentation to specify this is not supported AND we will emit a warning if we detect this property in some netcore run.

@Evangelink
We have about 1500 dlls of which 30-50 dlls need to be loaded at runtime depending on the project. via the .runsettings file gave us the possibility to specify a path where all possible runtime components can be found.
Surely we can't specify "Copy Local" on each of our projects, after which around 3 gigabytes of dlls are copied to the binary folder on each build, which would not only be a huge waste of memory, but also a massive performance loss when building the projects.

We are currently still using .NET Framework, but how should we solve the problem when we move to .NET 6.0 in the future?

from testfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.