Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vs2019 cannot run NUnit Tests - Issue with 'testhost.x86.exe'

I am created a selenium test framework using NUnit have have a test to open a pages and assert the page title.

However, when I try to run the test, its seems to start and stop without doing anything even running with Debug. The test remains in the not run state.

When I put a break point on { and run the test with debug, nothing changes. It starts and instantly stops without running the test.

Test:

[Test]
[TestCase(Browser.Chrome)]
public void ValidateWebDriverLaunches(Browser browser)
{
    Driver = StaticWebDriverFactory.GetLocalWebDriver(browser);
    Driver.Url = "https://example.com/";

    string title = Driver.Title;
    Assert.AreEqual(true, title.Contains("Example Domain"), "Title is not matching");
}

Error Log

'testhost.x86.exe' (CLR v4.0.30319: Domain 2): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
'testhost.x86.exe' (CLR v4.0.30319: Dependency finder domain): Unloaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'
The thread 0xcc has exited with code 0 (0x0).
'testhost.x86.exe' (CLR v4.0.30319: Domain 3): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
'testhost.x86.exe' (CLR v4.0.30319: Dependency finder domain): Unloaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'
The thread 0x2f90 has exited with code 0 (0x0).
The thread 0x2f80 has exited with code 0 (0x0).
The program '[8948] testhost.x86.exe' has exited with code 0 (0x0).

I have set the environment variable

__UNITTESTEXPLORER_VSINSTALLPATH__

to point to

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE

as some people have suggested. The only other suggestions I have found is updating VS17, however I am using VS19 and cannot find any information on this version.

like image 892
Ross Avatar asked Sep 24 '19 12:09

Ross


2 Answers

I figure out that the issue was myself.

I installed NUnit3TestAdapter nuget package and it works as expected now.

like image 148
Ross Avatar answered Sep 28 '22 01:09

Ross


It is required to switch process architecture in Visual Studio to 64.

Visual Studio: Test Tab -> Process Architecture for AnyCPU Projects -> 64

like image 23
Bahruz Balabayov Avatar answered Sep 28 '22 02:09

Bahruz Balabayov