This might be a feature that just doesn't exist in Visual Studio for Mac but I thought I might ask here to see if I'm doing something wrong.
I have an ASP.NET Core MVC project set as the startup project.
I also have a set of Unit Tests targeting .NET Core 2.0 that use Selenium to drive UI tests. In order to run these tests, I need the ASP.NET Core MVC running first before the tests can run otherwise they will fail because the app is not running.
In the PC version of Visual Studio, the "Start without Debugging" option in the "Debug" menu starts the web app as expected. My browser opens to my app. Once I confirm it's running, I'm able to run the tests without any issue (through the test explorer).
In the Mac version of Visual Studio, the "Start without Debugging" option in the "Debug" menu starts the web app as expected. My browser opens to my app. Once I confirm it's running, I attempt to run the tests. The tests do run but before they run, it kills the running app process. Since the app is no longer running, the tests fail.
TL;DR:
My solution:
Here are the steps on both instances of VS:
Expected: Tests pass in both PC and Mac version
Actual: Tests fail in Mac version because web app process is killed before tests are run
Does anyone have any suggestions for how I can achieve what I'm trying to achieve?
Looking at the Visual Studio Mac source code there is a restriction that prevents this. Visual Studio for Mac keeps a track of all applications that it has run and when you try to run the unit test it will attempt to close these applications.
Testing this with Visual Studio for Mac 7.1 a message dialog is displayed An application is already running and will have to be stopped. Do you want to continue?
when you run the tests.
Without changing the code you can only workaround this.
Workarounds:
More detail about option 3. To create a run configuration right click the solution and select Options. Then in the Solution Options create a run configuration in the Run - Configurations section. Then select it and check the web project and unit test project. In the status bar you will need to your run configuration. This should work if you can run your unit test project in Visual Studio for Mac. A unit test project that uses NUnit can be set as the startup project and running it will run the tests.