Skip to content

scm4j/scm4j-vcs-test

Repository files navigation

Release Build Status

Overview

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.

Terms

  • Test Base Dir
    • Home folder of all folders used by test. %temp%/scm4j-vcs-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

Test folders structure

  • %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

Overall testing process

  • 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.

Implementing VCS test

  • 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
  • Override getVCS(...) method. It must return Test VCS instance. Also this IVCS implementation must use provided mockedVCSRepo
    @Override
    protected IVCS getVCS(IVCSRepositoryWorkspace mockedVCSRepo) {
    	return new GitVCS(mockedVCSRepo);
    }
  • Override getVCSTypeString(). It must return short VCS name, e.g. "git", "svn" (same as IVCS.getVCSTypeString())
  • Override setMakeFailureOnVCSReset(Boolean doMakeFailure). It must make so next merge 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 of mockedVCSRepo.getLockedWoringCopy() call. If necessary it could be used for additional testing. See setMakeFailureOnVCSReset() in scm4j-vcs-git

Examples

See also