Debugging issue in Selenium Web driver project in C# - c#

How to resolve this issue given in image and I want to debug my project but there is an message generated that "add executable project to this solution". Please help

If you want to debug and work with your Automation Selenium tests in Visual Studio. You can create the project as a :
Console App : You can use the run button to start the project and then apply breakpoints where ever you want to do the debugging
Create a Unit test project and then using the test explorer, debug/run the tests as you prefer.

Related

Visual Studio 2017: Run tests with Startup Projects

I have a solution containing a few projects, three of which startup when hitting the Start button, which are integral to the operation of the program. I have some tests, which have been found by Visual Studio and are inside the Test Explorer panel.
The question is: When I hit the Run All button inside the Test Explorer panel, how can I tell Visual Studio to startup the same projects as when I hit the Start button?
The only way I can see it being done is by using a *.testsettingsfile to use a Setup script that will run the projects, but it just feels like a dirty way of doing it.
Any ideas?
Open two visual studio apps, one for running your three projects and the other for running the tests. But I think only functional/integration tests need to test the executions which are running currently.
The way I have accomplished this in the past for system tests that need the main executable running is to leverage the Assembly Initialize in the test project and have it start the required exe.
We have a build setup that puts all of our debug output into a common location, so we can find the appropriate exe because it is in the same path as the test assembly.
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
// Launch the exe here.
}

Visual Studio c# should NOT start IIS website when debugging unit tests

I have a VS (2013) solution containing two unittest project's and a seperate webproject. The webproject has no relation to the unittest projects. The unittest projects is covering integration test of another solution and the webproject is a dashboard showing the results of these tests. They dont require each other to run as the test results are stored on an external server.
My issue is:
When I debug one of my tests (right click + debug test), the webproject is also started and the IIS express will be running. While this does not affect my tests, it is very annoying. How do I make sure the webproject is not automatically started when debugging the tests? The project is NOT set as startup project.
I know that I could simply create two separate solutions, but I want to keep the projects in a single solution.
Thank you for your help.
Click on your webproject, hit F4, there is an option "Always start when debugging", you should turn-off this option.

ReSharper: "The build could not be started. There are multiple projects in the solution at..."

When trying to run NUnit tests with ReSharper, the following message appears in a dialog box and the tests are not run:
The build could not be started. There are multiple projects in the solution at... <name of the csproj file>
I have this problem with Resharper 8.2.1
I have several projects in my solution. Most of the projects are class libraries. One of the projects is a Web Site (not project exactly). Another one is a Web Application. The Web Site and the Web Application projects are located in the same directory. The Web Site is set to be built only in the Release build.
I have this problem only in The Web Application project, when I try to run some embedded tests in this project. I do not have this problem in other (class library) projects.
The problem was in JetBrains' bug tracker, but was closed: https://youtrack.jetbrains.com/issue/RSRP-328627
Perhaps there some workaround?
Update:
When I "Project -> Unload Project" on the Web Site, the problem disappears
I had the same problem (also with 8.2), at least the same error when running my tests through the menu Resharper > Unit Tests > Run All Tests from Solution. But I found the following work around :
Right click on your unit testing project and select Run Unit Tests. this will start running all the tests from the project (from the resharper interface)
Alternatively you can set up you unit testing solution as start up project and from the Resharper menu choose > Unit Tests > Run Unit Tests
Of course you have to do it for each project that has unit tests, but I guess this is acceptable.
Remark: it seems to be a known bug of version 8.2 https://youtrack.jetbrains.com/issue/RSRP-411631
And that rolling back to 8.1 can fix the problem
Hope this helps.
In my case this happened after running performance analysis (i.e. profiling) in Visual Studio.
As documented here, the solution was to remove these lines from the .sln file:
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection}
Check whether you have any changes to your solution file. I encountered this problem after a source control branch change, when Visual Studio held on to a bunch of changes from the previous branch. Not sure exactly what the cause was, but reverting the changes to my sln file fixed the issue.

running a c# test project through an exe file

I have a bunch of c# tests that I want to run through a powershell script. I am currently doing this by creating a windows application project, writing the tests as a part of a general class and compiling it into .exe and running the exe but its not the right way to go.
How can I, say, create a class (that can come out as .exe) that can run all tests in a given project or some other way that I can easily run all tests through a powershell script, which is used for application deployment
Try to use MSTest.exe. There are lots of parameters
Example from the link above.
mstest /testcontainer:Errors.dll /detail:testtype
or (VS90COMNTOOLS change to your version)
"%VS90COMNTOOLS%\..\IDE\MSTest.exe"/testcontainer:Errors.dll /detail:testtype
or (change 'Microsoft Visual Studio 11.0' to your VS folder)
"%PROGRAMFILES%\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Errors.dll /resultsfile:out

How to navigate to feature file from resharper test session window in Visual Studio 2012?

For acceptance testing I use TeckTalk SpecFlow in Visual Studio 2012. When I run all specflow scenarios, resharper unit test session windows is opened I can see all test results. Like on screen shot below.
The question is, when I see failed test (scenario) in some feature file, how can I navigate directly to this feature file from resharper session window to edit it???
A partial solution that only works when the test has failed is double-clicking on the test name in the resharper test sessions or unit tests window.
If the test failed last time it ran then this works perfectly, unfortunately it takes you to the feature.cs file if it last passed/ignored/unknown .
You can when you're in the feature.cs file use the shortcut to navigate solution explorer to the currently open file ( shift+alt+l by default) and then open the feature file as the file above the selected file in the solution explorer. It's not ideal, but it's better than nothing.
It seems to work perfectly well if run via the new VS2012 Test explorer, which on my machine worked automatically from "Run SpecFlow Scenarios" on the project menu. I can only assume Resharper is getting in the way on your machine.
Try Test->Run->All, then all you have to do is double click the test and it takes you straight to the scenario in question.

Categories

Resources