Code example for Test

Methods: toString

0
	 * 
	 * @see junit.framework.TestListener#addFailure(junit.framework.Test, 
	 *      junit.framework.AssertionFailedError) 
	 */ 
	public void addFailure(Test test, AssertionFailedError t) {
		if (alreadyReported.contains(test)) {
			logger.warn("Result for this test was already reported " + test);
			return; 
		} 
		logger.debug("Failure added for test: " + test);
		long duration = getDuration(test);
		failureMessages.add(new TestMessage(test.toString(), t.toString(),
				duration));
		alreadyReported.add(test);
	} 
 
	/* 
	 * (non-Javadoc) 
	 * 
	 * @see junit.framework.TestListener#endTest(junit.framework.Test) 
	 */ 
	public void endTest(Test test) {
		if (!alreadyReported.contains(test)) {
			long duration = getDuration(test);
			passingMessages.add(new TestMessage(test.toString(), "test passed",
					duration));
			alreadyReported.add(test);
			logger.debug("Test ended normaly:" + test);
		} 
	} 
 
	/** 
	 * Returns the duration for the test. 
	 * 
	 * @param test 
	 *            The test for which the duration is computed for. 
	 * @return The duration in milliseconds for this test. 
	 */ 
	private long getDuration(Test test) {
		long duration = 0;
		if (startTime.containsKey(test)) {
			duration = System.currentTimeMillis() - startTime.get(test);
		} else { 
			logger.warn("No start time for test: " + test);
		} 
		return duration;
	} 
Experience pair programming with AI  Get Codota for Java