What git branch should I commit unit tests to?
I’m currently following the ever-popular git workflow described here.
One thing it doesn’t discuss is how to handle unit testing. Let’s say I write some code and commit to
develop. I want to write a test for it, but I don’t want it in my
develop history, I’d like to keep the tests separate so that when I look at
git log I only see changes to the main code. However, if I commit the test to a separate
test branch, I’ll have to merge develop/test back and forth constantly, resulting in a ridiculous amount of merge commit clutter.
- Is it okay to merge individual files from one branch to another?
- Remove “obsolte” merge commits
- Git: subtree or submodule for personal projects?
- merging changes from a maven release branch yields conflicts due to changed versions in poms
- Why is putting git repositories inside of a Dropbox folder not recommended?
- Change trigger in Clear Case Remote Client
How do you manage unit testing in a git repository?
One Solution collect form web for “What git branch should I commit unit tests to?”
Unit tests are part of your source tree: They evolve as your code evolves, and feature branches have their own unit tests that evolve as the features evolve. There’s no reason to keep them in a separate branch.
git log accepts a path parameter, so if you want to avoid seeing test-only log entries, you can do the filtering at that point. I typically keep my
testsrc source folders separate and adjacent, so I can see changes to one or the other easily just by specifying
git log src or
git log testsrc.