Search code examples
gitjunitgit-bisect

Create new JUnit test and run with git bisect


If I get a bug report that says "Since this release I cannot longer enter negative values" then I would like to create a JUnit test for this.

@Test
assertCanPutNegative(){}

This testcase I would like to run on the latest 10 commits for example by doing

git bisect start
git bisect bad
git bisect good a4426026a056049504 <- commit known to work

then i would like to run my newly created testcase on all of these commits.

Can I do that easily with git bisect run mvn clean test (because my test will disappear in the bisecting process)?

Can i do something else in the run command to make this work?


Solution

  • You could do it like this:

    • create a new branch
    • add the test with a new commit
    • place the commit with rebase just after the last known working commit
    • run git bisect run mvn clean test