1

i use VS2013. I have a "normal project" and a testproject with some testcases to the "normal project". I can run the tests in test project - so far so good. But now, I want to run the tests automatically, when I rebuild my "normal project". Any ideas?

Thanks.

Cit
  • 113
  • 1
  • 10
  • I've only used some previous versions of Visual Studio but I arrange dependencies so that when I run the tests the solution builds everything that is needed first. – quamrana Oct 02 '14 at 12:50
  • Ok, a solution. But in normal case i'm in the "normal project"-environment and not in the test-project-environment. So, i need a solution for the "normal-project"-environment.... – Cit Oct 02 '14 at 12:56
  • I'm not sure I know the difference. Is this a VS2013 thing? – quamrana Oct 02 '14 at 12:57

2 Answers2

1

As was pointed out in the comments to my other answer, it is possible to add a postbuild step which will invoke the tests from the command line. The details can be found in this question.

Whilst this might be a suitable solution, I believe it is inferior to the continuous test runner approach for several reasons.

  • feedback is not integrated nice into the IDE in a test runner window, allowing for simple visual feed back and/or running of individual or groups of tests
  • Tests only run at build time. Continuous runners will run when changes are detected
  • All tests will be run on every save. Continuous runners can identify only the tests that have been affected by the change and run only those tests.
  • running individual tests will require using a different runner
  • running specified subsets of tests (ie excluding integration tests) will require changing the postbuild step. NCrunch can be configured to run filtered sets of tests.

Having said all that some of the runners are commercial products that are not cheap, (although some are Open Source and free). In the end you pays your money, you takes your choice.

Community
  • 1
  • 1
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
0

I don't know of anyway to do this in natively in VS but you should look into a tool like NCrunch, a continuous test runner, which will run your tests not only when you build your 'normal' project but also when you make any change to the project.

There are other continuous test runners out there, like MightyMoose, the source of which is here I believe

I'm in no way affiliated with NCrunch (or mighty moose), but I think its awesome and can't imagine life without it now.

Its not free though so whether its useful for you I can't say.

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
  • 2
    would the downvoter care to elaborate? – Sam Holder Oct 02 '14 at 13:17
  • Your answer is ``OffTopic``! My down vote! And yes ;) - you can. The post-build-option: ``CD $(TargetDir)`` ``"$(DevEnvDir)MSTEST.exe" /testcontainer:$(TargetFileName)`` @ http://stackoverflow.com/questions/507757/using-post-build-event-to-execute-unit-tests-with-ms-test-in-net-2-0 – raiserle Oct 09 '14 at 09:33
  • btw: ``I don't know``! **If you do not know it, you should not respond** – raiserle Oct 09 '14 at 09:37
  • @raiserle no offence but you take my `I don't know` out of context. what I said was `I don't know of anyway to do this natively` ie I don't think its possible to do what your question actually asks, but I then went on to say `but here is a way to solve your actual problem`. The suggestions I gave are , IMHO, better solutions that running tests when you save, and so might be a better solution that any actual solution to the question asked. And if you knew how to solve the OP actual problem why did you not answer the question? Then we could all learn something. – Sam Holder Oct 09 '14 at 09:44
  • also relevant: http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Sam Holder Oct 09 '14 at 09:45
  • Ok! Again! The question is ``I want to run the tests automatically, when I rebuild my "normal project". Any ideas?`` Not any other solutions. And ``IMHO`` is yours ... not the question! Btw: http://www.tty1.net/smart-questions_de.html You don't understand to give good answer! – raiserle Oct 09 '14 at 10:32
  • @raiserle thanks for the link, although its about questions I take your point but respectfully disagree. I provided an answer the *underlying problem* not the OP's *attempted solution*. I believe this answer, whilst not a solution to the direct question, provides a potential solution to the underlying problem and adds value, both to the OP and to others who might be trying to find a solution to a similar problem. – Sam Holder Oct 09 '14 at 10:41