-
Notifications
You must be signed in to change notification settings - Fork 325
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
Unable to specify custom test adapter path #4241
Comments
@MarcoRossignoli, the TestAdapterLoadingStrategy can be used to facilitate this. If you set it to |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 10 days. |
Ever tried something like that?
Because I just started to create from scratch and with some trial and error, this worked. Thus, I get the message that no test is found which is correct so far. HTH. :-) |
@holbizmetrics here is a minimal implementation of a discoverer and executor, and a test framework if you need some reference. Biggest hurdle is getting the attributes right (you already got that down), and having the dll named |
@nohwnd Yes. Meanwhile even the test appears in the Test Explorer in Visual Studio and one debug commands as well as the traits are working as well. The TestAdapter I already named correctly, but that was a coincidence. What worked for me was this: [ExtensionUri(DiscovererURI)] //[ExtensionUri("executor://NextUnitTestDiscoverer")]
DefaultExecutorUri(DiscovererURI)]//[DefaultExecutorUri("executor://NextUnitTestDiscoverer")]
[FileExtension(".dll")]
[FileExtension(".exe")]
[Category("managed")]
public class NextUnitTestDiscoverer : ITestDiscoverer
{
... In the TestDiscoverer. And in the TestExecutor: /// <summary>
///
/// </summary>
[ExtensionUri(Definitions.DiscovererURI)] //[ExtensionUri("executor://NextUnitTestDiscoverer")]
public class NextUnitTestExecutor : NextUnitBaseExecutor, ITestExecutor
{
... For anyone who may still encounter the same problem... P.S.: I don't know why the formatting now looks like this considering the code. Tried to change that multiple times. |
Fixed your comment, you need to use |
Firstly, to the original poster: As far as I understand it is the normally behavior THAT *.TestAdapter.dll will be called. *.TestAdapter.dll But other hints have been added already.
|
There is a built in collection of env variables that will wait for you to attach debugger to host or runner: VSTEST_HOST_DEBUG=1 Or if you use our Playground, or build the AttachVS project that is part of our solution, and put the exe on PATH. Then it can attach automatically back to your VS. Either the one that started the execution, or one of your choosing: VSTEST_RUNNER_DEBUG_ATTACHVS=1 If you set 1 in this env variable it will take the current process and search for parent VS. If you set any other positive number, it will try to find that process ID and will try to find parent ID. |
Sorry for the late reply. Before this suggestion, I had taken a different approach to solving this and lost track of this issue, which works fine for Windows. But it's not working for Unix systems. I was just renaming the test adapter files to achieve my use case. My adapter was named like I tried the above but was still not able to achieve this. It's always picking the nunit/xunit adapters over my adapter. The .runsettings file I used:
Any help is appreciated @Haplois . |
We don't allow to specify order in which test adapters will load, nor we can guarantee it. The name migh work, but it also can be trumped by visual studio or other client that will send additional extension to the run etc. |
@nohwnd, is there any way to achieve this? Basically, I want my adapter(which only contains the test executor) to be used for Test Execution and the NUnit/Xunit's adapter for Test Discovery. |
Only way I can see is that you grab the dlls of xunit and nunit adapters, ship them with your adapter (and rename them from This way vstest is oblivious to the fact that you have xunit and nunit adapters installed, and only uses your adapter. In other cases all registered executors will try to run tests. |
@nohwnd got it, but this will make the nunit/xunit adapter version static. If we can somehow use the discoverer class of nunit/xunit's adapter inside our adapter and remove it from the |
Yes you can do a lot of different hacks, but they don't sound like good maintainable solutions. |
I agree but it seems there is no straightforward way to do it. Anything working should be fine for now :\ |
Description
I am trying to create a custom test adapter which is intended to run before nunit3.testadapter. I have a requirement of executing tests with custom test adapter and for some conditions tests should run using nunit3.testadapter executor something like this.
I tried out the following solutions:
dotnet test --test-adapter-path C:\Adapters
vstest.console.exe dll_path /TestAdapterPath:"C:\Adapters"
RunConfiguration.TestAdaptersPaths
node as given below and specified this runsettings path todotnet test
but every time *.TestAdapter.dll from source dll directory is getting picked.
The custom test adapter should be picked in an ideal scenario, but this isn't working. Can someone please help me to achieve this?
Steps to reproduce
Expected behavior
Custom test adapter should be picked.
Actual behavior
*.TestAdapter.dll
at source dll directory is picked.Diagnostic logs
Environment
The text was updated successfully, but these errors were encountered: