Should it be changed in the code separately from the corresponding change to the test suite?

Should the code change and corresponding change in the test suite be performed in one commit or split into two? Consider the case of error correction, which causes a slight change in the expected result, which leads to minor changes in the test suite. It is very convenient to have both changes in the same commit, as this makes it obvious to the reviewer what has changed as a result. On the other hand, sometimes you just need to look at diff for the source or the difference with the expected output, and it is much easier to do if the commits are separate. In addition, the two things are logically different, so it makes sense to make clear commits.

I would like to make two different commits, but somehow they have two connections that are related to each other (so that I can select, return, etc. both are fixed as an atomic unit). In addition, if two excellent commits are made, then the test suite will fail on the first commit (unless a third commit is introduced to weaken the test suite), which will lead to pain in the future. The problem with future bisects, which does not work at all, generally encourages me to make one commit, but the commits should be logically different units, and the commit code is logically different from the commit to the expected result in the test suite.

Is there a way to make two excellent fixations and not bend backwards to prevent bisection on one of them? (e.g. to explicitly specify commits to skip)

+6
source share
2 answers

Definitely save these changes (code and unit test) as a single commit: SCM can also reproduce this state, and this includes both the program and its tests.

If you need to see only code changes, do git diff on src , not tst .
Since these related changes remain in a single commit, you completely eliminate the bisect problem.

In short, keep it simple;)

+3
source

If you like, you can save them in separate commits in the development branch. After each pair of commits, merge into a function branch. This should give you the opportunity to do it anyway.

0
source

Source: https://habr.com/ru/post/889699/


All Articles