1

I have a VS Solution the structure of which you can see here:

Solution Explorer Screenshot

I'm using NUnit 3.2.0 to run my tests.

How can I stop commits to my local branch if the NUnit test fails and display a message on the Git bash?

I read something about pre-commit hooks. How do I implement that here?

I'm using the NUnit Console Runner to test my UnitTests.dll using the following command line argument:

nunit3-conosle.exe UnitTests.dll /wait

P.S. Please let me know in the comments if you require more information regarding this.

7
  • 1
    You shouldn't really be running unit tests on commit. See here: programmers.stackexchange.com/questions/260778/…
    – Steve
    Mar 31, 2016 at 4:38
  • @Steve If you read this programmers.stackexchange.com/a/260862. Mar 31, 2016 at 4:46
  • @Steve I agree as to why shouldn't run unit tests on commit, but I'm okay with the trade off. Mar 31, 2016 at 4:48
  • 1
    I can see the point to both sides. Personally I wouldn't run on commit but would have a continuous build running on each push set to fail if a unit test fails. In my view commits should be quick and painless and there are circumstances you may want to commit broken code - to get a colleague to work on it for example. Ultimately it's up to you, just thought I'd point it out.
    – Steve
    Mar 31, 2016 at 4:50
  • @Steve I understand what you're trying to say. But I've been asked to have a continuous build running on each commit set to fail if unit test fails. I would have used something like Jenkins to take care of things for me if it was up to me. But, thank you for the comments. :) Mar 31, 2016 at 4:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.