Mercurial > hg4j
diff test/org/tmatesoft/hg/test/TestManifest.java @ 103:0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 28 Jan 2011 04:57:46 +0100 |
parents | a3a2e5deb320 |
children | 5c43e937e15b |
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestManifest.java Fri Jan 28 03:50:52 2011 +0100 +++ b/test/org/tmatesoft/hg/test/TestManifest.java Fri Jan 28 04:57:46 2011 +0100 @@ -16,20 +16,24 @@ */ package org.tmatesoft.hg.test; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.tmatesoft.hg.repo.HgRepository.TIP; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Map; import org.junit.Assume; +import org.junit.Rule; import org.junit.Test; import org.tmatesoft.hg.core.LogCommand.FileRevision; import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.core.Path; import org.tmatesoft.hg.core.RepositoryTreeWalker; +import org.tmatesoft.hg.repo.HgLookup; import org.tmatesoft.hg.repo.HgRepository; -import org.tmatesoft.hg.repo.HgLookup; /** @@ -39,6 +43,9 @@ */ public class TestManifest { + @Rule + public ErrorCollectorExt errorCollector = new ErrorCollectorExt(); + private final HgRepository repo; private ManifestOutputParser manifestParser; private ExecHelper eh; @@ -54,11 +61,12 @@ public void begin(Nodeid manifestRevision) {} }; - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Throwable { TestManifest tm = new TestManifest(); tm.testTip(); tm.testFirstRevision(); tm.testRevisionInTheMiddle(); + tm.errorCollector.verify(); } public TestManifest() throws Exception { @@ -100,26 +108,13 @@ private void report(String what) throws Exception { final Map<Path, Nodeid> cmdLineResult = new LinkedHashMap<Path, Nodeid>(manifestParser.getResult()); - boolean error = false; for (FileRevision fr : revisions) { Nodeid nid = cmdLineResult.remove(fr.getPath()); - if (nid == null) { - System.out.println("Extra " + fr.getPath() + " in Java result"); - error = true; - } else { - if (!nid.equals(fr.getRevision())) { - System.out.println("Non-matching nodeid:" + nid); - error = true; - } + errorCollector.checkThat("Extra " + fr.getPath() + " in Java result", nid, notNullValue()); + if (nid != null) { + errorCollector.checkThat("Non-matching nodeid:" + nid, nid, equalTo(fr.getRevision())); } } - if (!cmdLineResult.isEmpty()) { - System.out.println("Non-matched entries from command line:"); - error = true; - for (Path p : cmdLineResult.keySet()) { - System.out.println(p); - } - } - System.out.println(what + (error ? " ERROR" : " OK")); + errorCollector.checkThat("Non-matched entries from command line:", cmdLineResult, equalTo(Collections.<Path,Nodeid>emptyMap())); } }