I have a Python script which is responsible for updating SVN repository (in a nutshell) and checking it.
Now I'd like to write some functional tests for the script. To check whether SVN update has been performed correctly, I have an idea for manual test scenario, to check at first revision number of a particular path, perform actual SVN update and check if revision number is changed.
But I'm wondering what is the best way to test anything like that with Python.
Should I really perform the SVN update, which may take a lot of time? Or maybe this is a good place for mocks? (I've never used any mocks, but as fair as I know they are mainly dedicated for unit testing, not functional testing). If mocks are okay - could you advise me how to design such kind of a test?
1 Answer 1
It depends on what your script exactly does, which logic it performs and in which part of the script you expect the most bugs.
For example, if the script collects some files by some specific rules and then generates one or more fairly simple command line calls utilizing the svn
command line program, mocking the call to svn
is probably ok - you want to test the rules, not correctness of the svn
command.
However, if the functional correctness depends on a complex parameter set for the svn
command generated by the Python script, you maybe better off to test the "real" thing with no mocks (but not against your real production repo). I would recommend to use a local file repo, not a full-blown SVN server, for such a test. That way, as a test preparation, you can easily copy a small, prepared repository folder into a working directory and do all checkins / checkouts against this local copy. This gives you always a defined baseline for the tests.
Note further, if the script is not large and unlikely to be changed later, you should also consider if creating an automated test is really worth the hassle, and if manual testing is not enough.
Explore related questions
See similar questions with these tags.
git
(or other VCS) can be used as efficiently assvn
. So if OP struggles on scripting above svn deficiencies, he might consider upgrading the VCS too