Mock svn instance for testing svnkit tests

纵饮孤独 提交于 2019-12-12 11:51:33

问题


A project I'm working on interacts heavily with Subversion, using svnkit.

Are there any examples on running a mock in-memory svn instance, to help facilitate testing etc?

Cheers

Marty


回答1:


It's quite straightforward to create a temporary SVN repository on the filesystem to use during the test which you can delete immediately at the end of the test. You would use file:// protocol to access it.

import static org.junit.Assert.*;
import java.io.*;
import org.apache.commons.io.FileUtils;
import org.junit.*;
import org.tmatesoft.svn.core.*;

public class SVNTest {

    private static final String path = "/tmp/testrepo";
    SVNURL tgtURL;

    @Before
    public void setUp() throws Exception {
        SVNRepositoryFactoryImpl.setup();
        tgtURL = SVNRepositoryFactory.createLocalRepository( new File( path ), true , false );
    }

    @After
    public void tearDown() throws IOException {
        FileUtils.deleteDirectory(new File(path));
    }

    @Test
    public void test() {
        fail("Not yet implemented");
    }

}



回答2:


Why don't you just create a simple SVN repository with mock data ? It's just a few commands.




回答3:


you may be intested in mockito, that should work fine with SVNkit

my 0.02$



来源:https://stackoverflow.com/questions/876993/mock-svn-instance-for-testing-svnkit-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!