scm4j-vcs-test project provides set of functional tests for implementations of IVCS interface declared in scm4j-vcs-api. It used as maven dependency for scm4j-vcs-git, scm4j-vcs-svn.
- Test Base Dir
- Home folder of all folders used by test.
%temp%/scm4j-vcs-test
- Home folder of all folders used by test.
- Test Workspace Dir
- Home folder of all LWCs which are used by Test VCS
- Locked Working Copy, LWC
- Folder where vcs-related operations are executed. Provides thread- and process-safe repository of working folders. See scm4j-vcs-api for details
- Test Repository
- A VCS Repository which is used to execute vcs operations which are being tested.
- New Test Repository is generated before and deleted after each test
- Named randomly (uuid is used)
- Test VCS
- An IVCS instance which is testing now
- Test Data Gen
- Test Data Generator. An IVCS instance which is used to generate test data only
- works in separate Locked Working Copies to avoid situations when current LWC already contains data which existance is testing now due of generating test data within the same LWC
%temp%/scm4j-vcs-test
/base-repo
- Test "server" repository to pull from, push to and clone from.
/workspaces
- LWCs for VCS which is testing now
/test-data-gen
- LWCs for Test Data Gen VCS
- Empty Test Base Dir is created
- A new Test Repository named as
"scm4j-vcs-" + getVCSTypeString() + "-testrepo_" + uuid
is generated - A test method executes
- test data is generated by Test Data Gen
- VCS method is executed, result is verified
- Mocks are verified. LWC closing is checked if one was obtained
- Test Base Dir folder deletes.
- Add github-hosted scm4j-vcs-test project as maven dependency using jitpack.io. As a gradle example, add following to gradle.build file:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
// versioning: master-SNAPSHOT (lastest build, unstable), + (lastest release, stable) or certain version (e.g. 1.0)
testCompile 'com.github.scm4j:scm4j-vcs-test:+'
}
Or download release jars from https://github.com/scm4j/scm4j-vcs-test/releases
- Create VCSAbstractTest subclass within test package
- Override
setUp()
method- Call
super.setUp()
- Create a Test Repository using
VCSAbstractTest.repoUrl
as the repository url
- Call
- Override
getVCS(...)
method. It must return Test VCS instance. Also this IVCS implementation must use providedmockedVCSRepo
@Override
protected IVCS getVCS(IVCSRepositoryWorkspace mockedVCSRepo) {
return new GitVCS(mockedVCSRepo);
}
- Override
getVCSTypeString()
. It must return short VCS name, e.g. "git", "svn" (same asIVCS.getVCSTypeString()
) - Override
setMakeFailureOnVCSReset(Boolean doMakeFailure)
. It must make so nextmerge
operation will fail on LWC reset caused by merge conflict. This need to test LWC corruption. See examples below. - Use
localVCSWorkspace
field as Test Workspace Dir - Use
repoName
field to get current testing repository name. It generates new for each test randomly (uuid is used) - Use
repoUrl
field to get url to current Test Repository. - Use
vcs
field as current IVCS implementation which is being testing mockedLWC
returns each time as a result ofmockedVCSRepo.getLockedWoringCopy()
call. If necessary it could be used for additional testing. SeesetMakeFailureOnVCSReset()
in scm4j-vcs-git