Arjun K R
Arjun K R

Reputation: 462

Generate runnable exe from MSTest test

I have a [TestMethod] in a visual studio test project. If I build the project, I get a dll. I dont want to run the tests from the visual studio User Interface.

  1. Is there any way to generate an exe of a test project so that i can run the tests from command prompt?

  2. If I change the project type from Class Library to Console Application, then it requires a Main function. Is there any way to call a TestMethod from the Main()

Upvotes: 3

Views: 6099

Answers (4)

Ian Gilroy
Ian Gilroy

Reputation: 2041

You should already have an EXE that can execute your tests - mstest.exe. If you need to run your tests outside Visual Studio - and you're not using some kind of build automation solution that can already do this for you - then you can call mstest.exe and have it execute your tests.

http://msdn.microsoft.com/en-us/library/ms182489(VS.100).aspx

Upvotes: 3

schei1
schei1

Reputation: 2487

You can run the unit tests inside Visual studio through the menu: Test -> Run -> ...

Two options: - Tests in current context - All tests

Context could either be project level, class level or method level. Depends on where you put your marker inside the test class or if you have selected a class/file/project in the solution explorer.

You can use the hotkey combination CTRL + R, T to run tests in current context or CTRL + R, A to run all tests.

EDIT: ref comment.

Upvotes: 2

abatishchev
abatishchev

Reputation: 100238

You may want to utilize TFS - Microsoft Team Foundation Server, a stand-alone server-side application system to build a project and run tests inside it.

Also you can run them inside Visual Studio (menu Tests -> Run -> ...).

Upvotes: 0

memory of a dream
memory of a dream

Reputation: 1267

I think what you want is some sort software for test automation. My company uses Jenkins. Works really well, and you can use it together with source control software as well, to run the tests when someone checks something in.

Upvotes: 0

Related Questions