vendredi 6 février 2015

Emulate Git repo in JUnit

In a recent project I have the need to test a Java class that makes use of a specific Git repository. For the class to work it has to take a path to the repository and then do its magic.


What I'm interested in is whether it is possible to emulate a Git repository in JUnit, or by any other means provide a mock repository with which the class could be tested.


Using an actual Git repository dedicated to this tests would be an option, but because of the nature of the environment it could be difficult to ensure that the tests could be run from every machine that another developer may use to run the tests. Furthermore the actual repository isn't small and it would take at least 10 minutes to clone it.


So far I wasn't able to find any way to emulate a repository with maybe 10 - 15 commits inside a JUnit test class so every suggestion is welcome.


Oh yes, the repository would ideally also have multiple subrepositories/submodules, but I would also be happy with a solution that provides a single repo.


Aucun commentaire:

Enregistrer un commentaire