001: package org.testng.remote.strprotocol;
002:
003: import org.testng.ITestContext;
004:
005: /**
006: * An <code>IStringMessage</code> implementation for test events.
007: *
008: * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
009: */
010: public class TestMessage implements IStringMessage {
011: protected final boolean m_testStart;
012: protected final String m_suiteName;
013: protected final String m_testName;
014: protected final int m_testMethodCount;
015: protected final int m_passedTestCount;
016: protected final int m_failedTestCount;
017: protected final int m_skippedTestCount;
018: protected final int m_successPercentageFailedTestCount;
019:
020: TestMessage(final boolean isTestStart, final String suiteName,
021: final String testName, final int methodCount,
022: final int passedCount, final int failedCount,
023: final int skippedCount, final int percentageCount) {
024: m_testStart = isTestStart;
025: m_suiteName = suiteName;
026: m_testName = testName;
027: m_testMethodCount = methodCount;
028: m_passedTestCount = passedCount;
029: m_failedTestCount = failedCount;
030: m_skippedTestCount = skippedCount;
031: m_successPercentageFailedTestCount = percentageCount;
032: }
033:
034: public TestMessage(final ITestContext testContext,
035: final boolean isTestStart) {
036: this (isTestStart, testContext.getSuite().getName(), testContext
037: .getName(), testContext.getAllTestMethods().length,
038: testContext.getPassedTests().size(), testContext
039: .getFailedTests().size(), testContext
040: .getSkippedTests().size(), testContext
041: .getFailedButWithinSuccessPercentageTests()
042: .size());
043: }
044:
045: public boolean isMessageOnStart() {
046: return m_testStart;
047: }
048:
049: /**
050: * @see net.noco.testng.runner.IStringMessage#getMessageAsString()
051: */
052: public String getMessageAsString() {
053: StringBuffer buf = new StringBuffer();
054:
055: buf.append(
056: m_testStart ? MessageHelper.TEST_START
057: : MessageHelper.TEST_FINISH).append(
058: MessageHelper.DELIMITER).append(m_suiteName).append(
059: MessageHelper.DELIMITER).append(m_testName).append(
060: MessageHelper.DELIMITER).append(m_testMethodCount)
061: .append(MessageHelper.DELIMITER).append(
062: m_passedTestCount).append(
063: MessageHelper.DELIMITER).append(
064: m_failedTestCount).append(
065: MessageHelper.DELIMITER).append(
066: m_skippedTestCount).append(
067: MessageHelper.DELIMITER).append(
068: m_successPercentageFailedTestCount);
069:
070: return buf.toString();
071: }
072:
073: public String getSuiteName() {
074: return m_suiteName;
075: }
076:
077: public String getTestName() {
078: return m_testName;
079: }
080:
081: public boolean isTestStart() {
082: return m_testStart;
083: }
084:
085: public int getTestMethodCount() {
086: return m_testMethodCount;
087: }
088:
089: public int getSuccessPercentageFailedTestCount() {
090: return m_successPercentageFailedTestCount;
091: }
092:
093: public int getFailedTestCount() {
094: return m_failedTestCount;
095: }
096:
097: public int getPassedTestCount() {
098: return m_passedTestCount;
099: }
100:
101: public int getSkippedTestCount() {
102: return m_skippedTestCount;
103: }
104: }
|