Target framework drop down missing [duplicate] - c#

How can I unit test a Windows 10 app in Visual Studio 2015?
I created a Blank App Universal Windows project and added a new Unit Test Project to the solution, but when I try to add a reference to my UWP app in the Test Project, I get an error saying 'Unable to add a reference to project "Project Name"'.

Right click on your solution and choose Add > New Project. Then select Unit Test App (Windows Universal). Make sure that you don't select Unit Test Library or Unit Test Project. It must be the Universal one. This should generate a base class for you to work with.
You'll probably then want to add a reference to your main project. To do this, right click on your test project and select Add > Reference and then choose your main project. You should now be able to create classes from your main project to test.

I can understand the confusion - the Visual Studio team is not consistent in there otherwise fine project hierarchy decisions.
Normal approach was to place Test projects under Test. For reasons unknown, they decided to place the Unit Test App (Universal Windows) directly under Windows -> Universal and hereby bypassing common sense.
In summary; Test projects for Windows -> Classic Desktop and Web is placed under Test. Test projects for Windows -> Universal is placed under Windows -> Universal.

Try RT-Clicking on a function name & see if there is a "Create Unit Tests" option on the context menu. For some reason adding a new unit test project is buggy, but the context menu worked for me.

Related

ASP.NET MVC unit testing

I have created a program in Visual Studio 2017, and I just noticed now that I forgot to add unit testing when creating it, and I am too far gone to start over.
How can I solve this problem?
You should be able to right-click on the solution, and Add Project, then Unit Test Project. Unless you're not using MSTest, then add a new project and choose class library.

How to Create a visual studio Setup Project to install multiple Windows Services

I have 3 windows service with separate solutions. How can I install all the three with one visual studio Setup Project.
It's not clear why this is a difficulty, but perhaps you are stuck with the idea that the "project output" idea in a setup project means that you can have only one solution's output in a setup project.
The easiest thing to do is to create the setup project and then add (to the Application Folder) each of the service executables (which I assume have installer classes). Then add the three service executable installer classes as custom actions. To state the obvious, you allowed to have more than one custom action to install a service.

Project template type determination in visual studio after its creation

I have a solution in visual studio with multiple projects under it. Is there any way to determine which type of project it is?
Is it a unit Test project or a coded UI test project ..? One way to determine is by the icon of project but I noticed that they have similar icons for the Coded UI project and Unit Test Project.

why my test project doesn't appear on test explorer

I am using VS2012 (v110)
I create a simple dll application with only 1 function and a test project to test the dll function. I set up both projects to be debug builds for win32 and tried Clean and Rebuild both projects but I don't see any test to be run on the test Explorer windows.
I also reference Dll project in the test project already.
Why isn't there anything shown in Test Explorer windows?
Actually MSTest doesn't work with simple class library projects.
You will have to create a unit test project and place your tests there.
If you use other testing frameworks like NUnit, then you can use plain class library. You can then use NUnit to run the tests outside VS, or use tools like ReSharper to run those tests inside VS
It seems you have used some test frameworks other that MSTest. If you want to use Test Explorer for some other frameworks you should install its runner too. for instance NUnit needs to install its test adapter as and extension in VS.NET
see here for more.
You should be able to modify an existing class library project to get mstest to recognize it as a test project by modifying the ProjectTypeGuids in the .csproj file as detailed in this answer How to get VS2010 to recognize my mstests generated by SpecFlow? (Look for the answer that lists the specific guids and not the currently accepted answer which says to just create a new project.)
Have had a simular problem. Solved it. I have been adding tests project to my VS 2012 solution and tests were not appearing in Test Explorer. Problem was that test project was located in IIS inetpub\wwwroot folder which didn't have windows user rights to modify it. Adding solution folder Windows user rights to modify it solved issue. Tests are now visible in test explorer and able to be debugged. I assume that vstest.discoveryengine.exe process with is run by windows user was not having access to test project files

How to debug a class library in Visual Studio

I am working on a class library (DLL) project in Visual Studio 2008; programming in C#. In order to test my DLL I just created a second project that is a console application and in that project I can reference the first and run tests. Is there a simpler way of doing this? Can I just create another file within my class library project that has the tests in it and then somehow tell Visual Studio to run that file?
I know one way would be to add a text file to my project and then write my test code in JScript. Then in the Project settings on the debug menu I can tell it to Start External Program (JScript). Then, the name of my test file, test.js, goes in the Command Line Arguments box. But, I am wondering if there is a way to do it using C# code instead of JScript?
You could add a testing project to your current solution, then set that project as the startup project. Then, hitting F5 on your class library project will start your testing project.
Take a look at NUnit or other similar unit testing framework.
The "Team Developer" and "Team Suite" flavors of Visual Studio already have Microsoft's unit testing framework built in.
Create a unit test project for the class library by using the right-click "Create Unit Tests" in a class/method in the library. I would recommend downloading TestDriven.NET and using the right-click test runner in it.
Are you talking about unit tests? You can use something like nUnit or the built in testing framework that comes with Visual Studio. The simplest tests just require you to add some attributes to your test fixture and make an assertion like obj1 == obj2.
Checking out something like Test-Driven Development (TDD), Domain-Driven Development (DDD) or Behavioral-Driven Development (BDD) may be beneficial. I like to use nUnit with nBehave, myself.

Categories