Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test Subversion functions?

I am implementing an application that involves some svn functions.

I'm gonna write some unit tests for the app, however, how would you suggest I write unit tests for svn commands such as checkout, update, status, etc?

Thanks!

like image 445
nubela Avatar asked Oct 20 '25 04:10

nubela


2 Answers

Wrap your SVN-specific code within a class, implementing an interface. When unit testing your main application, stub/fake/mock/whatever your SVN class via the interface. You can then unit test most of your application this way.

Testing the actual SVN interaction will not be a unit test, but rather an integration test. You can write your test cases directly to your SVN implementation.

like image 150
Grant Palin Avatar answered Oct 22 '25 17:10

Grant Palin


You could:

  • Use a stub instead of the real svn command; the stub could log its invocations and, at the end of the test, you can check that svn has been invoked as you intended (this is more like a mock than a stub).
  • Create a "sandbox" repository in a temporary directory and perform actual operations on it, like I did in this answer.
like image 24
Danilo Piazzalunga Avatar answered Oct 22 '25 18:10

Danilo Piazzalunga