src/test/java/org/jenkinsci/plugins/pretestedintegrationmercurial/MercurialTest.java
public void testShouldGiveNextCommit() throws Exception {

		setup();
		File dir = createTempDirectory();
		MercurialBridge plugin = new MercurialBridge(false,"test","");
		plugin.setWorkingDirectory(new FilePath(dir));

		System.out.println("Creating test repository at repository: " + dir.getAbsolutePath());
		Date date = new Date();
		hg(dir,"init");
		shell(dir,"touch","foo");
		hg(dir,"add","foo");
		hg(dir, "commit","-m","\"added foo\"");
		String rev = hg(dir,"tip","--template","{node}").toString();
		hg(dir, "branch","test");
		shell(dir,"touch","bar");
		hg(dir, "add","bar");
		hg(dir, "commit","-m","\"added bar\"");
		
		MercurialSCM scm = new MercurialSCM(null,dir.getAbsolutePath(),"test",null,null,null, true);
		FreeStyleProject project = Hudson.getInstance().createProject(FreeStyleProject.class, "testproject");
		project.setScm(scm);
		
		//Setup build and listener
		OutputStream out = new ByteArrayOutputStream();
		BuildListener blistener = new StreamBuildListener(out);
		//FreeStyleBuild build = new FreeStyleBuild(project);	
		Future<FreeStyleBuild> f = project.scheduleBuild2(0);
		FreeStyleBuild build = f.get();
		System.out.println("Revision: " + rev);
		assertNotNull(plugin.nextCommit(build, launcher, blistener, new Commit<String>(rev)));
		//assertTrue(plugin.hasNextCommit(build, launcher, blistener));
		//assertTrue(plugin.commitFromDate(build, launcher, blistener, date).getId().equals(rev));
		cleanup(dir);
	}
/**
	 * Given that there are commits after a specified time
	 * When commitFromDate is invoked
	 * Then the next commit is returned
	 * @throws Exception
	 */
Given that there are commits after a specified time
When commitFromDate is invoked
Then the next commit is returned
@throws Exception
Given that there are commits after a specified time When commitFromDate is invoked Then the next commit is returned @throws Exception
public void testShouldGiveNextCommit() throws Exception {
		setup();
		File dir = createTempDirectory();
		MercurialBridge plugin = new MercurialBridge(false,"test","");
		plugin.setWorkingDirectory(new FilePath(dir));
		System.out.println("Creating test repository at repository: " + dir.getAbsolutePath());
		Date date = new Date();
		hg(dir,"init");
		shell(dir,"touch","foo");
		hg(dir,"add","foo");
		hg(dir, "commit","-m","\"added foo\"");
		String rev = hg(dir,"tip","--template","{node}").toString();
		hg(dir, "branch","test");
		shell(dir,"touch","bar");
		hg(dir, "add","bar");
		hg(dir, "commit","-m","\"added bar\"");
		MercurialSCM scm = new MercurialSCM(null,dir.getAbsolutePath(),"test",null,null,null, true);
		FreeStyleProject project = Hudson.getInstance().createProject(FreeStyleProject.class, "testproject");
		project.setScm(scm);
		OutputStream out = new ByteArrayOutputStream();
		BuildListener blistener = new StreamBuildListener(out);
		Future<FreeStyleBuild> f = project.scheduleBuild2(0);
		FreeStyleBuild build = f.get();
		System.out.println("Revision: " + rev);
		assertNotNull(plugin.nextCommit(build, launcher, blistener, new Commit<String>(rev)));
		cleanup(dir);
	}
public void testShouldGiveNextCommit ( ) throws Exception { setup ( ) ; File dir = createTempDirectory ( ) ; MercurialBridge plugin = new MercurialBridge ( false , "test" , "" ) ; plugin . setWorkingDirectory ( new FilePath ( dir ) ) ; System . out . println ( "Creating test repository at repository: " + dir . getAbsolutePath ( ) ) ; Date date = new Date ( ) ; hg ( dir , "init" ) ; shell ( dir , "touch" , "foo" ) ; hg ( dir , "add" , "foo" ) ; hg ( dir , "commit" , "-m" , "\"added foo\"" ) ; String rev = hg ( dir , "tip" , "--template" , "{node}" ) . toString ( ) ; hg ( dir , "branch" , "test" ) ; shell ( dir , "touch" , "bar" ) ; hg ( dir , "add" , "bar" ) ; hg ( dir , "commit" , "-m" , "\"added bar\"" ) ; MercurialSCM scm = new MercurialSCM ( null , dir . getAbsolutePath ( ) , "test" , null , null , null , true ) ; FreeStyleProject project = Hudson . getInstance ( ) . createProject ( FreeStyleProject . class , "testproject" ) ; project . setScm ( scm ) ; OutputStream out = new ByteArrayOutputStream ( ) ; BuildListener blistener = new StreamBuildListener ( out ) ; Future < FreeStyleBuild > f = project . scheduleBuild2 ( 0 ) ; FreeStyleBuild build = f . get ( ) ; System . out . println ( "Revision: " + rev ) ; assertNotNull ( plugin . nextCommit ( build , launcher , blistener , new Commit < String > ( rev ) ) ) ; cleanup ( dir ) ; }
Given that there are commits after a specified time
 When commitFromDate is invoked
 Then the next commit is returned
 @throws Exception
Given that there are commits after a specified time When commitFromDate is invoked Then the next commit is returned @throws Exception
//Setup build and listener //FreeStyleBuild build = new FreeStyleBuild(project);	 //assertTrue(plugin.hasNextCommit(build, launcher, blistener)); //assertTrue(plugin.commitFromDate(build, launcher, blistener, date).getId().equals(rev));