-2

I am using Jest unit testing in a folder called test in root, and I am trying to unit test nodejs on multiple branches. Are project is set in a git repository. When my team is done with a branch they will merge it with master. Normally I'd work on master if I was using code, but I'd like to do some things on their branches. Usually I don't touch other branches if the code isn't complete, but since this is for the intent of unit testing their code, and not developing it, I think it's ok to look at their latest commits on branch1 and branch2. Am I correct that this is correct to do so, and if so what would be the best way to use git in this situation?

EDIT - The main problem is that they will not merge without having large changes in between merging, and what I test now can and will be vastly different than what it was on master.

This is how my team is expecting me to solve the issue, but I'm starting to think that the issue itself is how my team using git on a whole separate branch.

zissler
  • 107
  • 1
  • 1
  • 11
  • This isn't very clear to me - your unit tests are presumably stored alongside the code to be tested, so what's the issue here? – Oliver Charlesworth Jan 05 '18 at 00:13
  • Are you asking if it's ok to look at someone else's branch and run their tests on that branch? This seems to be a social issue, not a technical one. Or are you asking how to deal with a situation where tests are only run *after* merging and branches are allowed to get very large? – Schwern Jan 05 '18 at 00:14
  • This probably has nothing to do with git, and probably nothing to do with *unit* testing (maybe acceptance testing). Also probably not on-topic for stackoverflow: https://stackoverflow.com/help/on-topic – tkruse Jan 05 '18 at 02:40
  • 1
    also see here: https://stackoverflow.com/questions/18371741/git-branching-strategy-integated-with-testing-qa-process – tkruse Jan 05 '18 at 02:42
  • It was suppose to be more of a git question, and what is the normal procedure to unit test? I know normally it would just be the team assigned to the branch, but that's not how it was assigned. Should I go back to my team and ask to branch their branches instead of being a solo branch? – zissler Jan 05 '18 at 21:29

1 Answers1

-1

One way I've found that could potentially solve the issue is to have all unit tests in a test folder that is not being tracked. By doing so I can just checkout each branch. That way my tests stay the same, but I can go from one branch to the next to collect unit tests as needed, and when I'm ready to create a new branch and commit my changes.

Example of the code would be after committing changes:

echo ":path_to_test_folder" >> .gitignore
git rm -r --cached :test_folder
git add .gitignore
git commit -m "Ignoring test folder"
git stash
git checkout other_branch

and the folder will with the tests will still be there. When I'm done I simply checkout my branch, commit, and push changes. It's a workaround, but it works for me.

zissler
  • 107
  • 1
  • 1
  • 11
  • It seems that you are probably using an idiosyncratic definition of "unit test". So it's not really clear what your original problem was, nor how this approach solves it! – Oliver Charlesworth Jan 06 '18 at 17:44