Search in sources :

Example 1 with TestStatus

use of org.eclipse.n4js.tester.domain.TestStatus in project n4js by eclipse.

the class CliTestTreeXMLTransformer method stringifyTestCase.

private StringBuilder stringifyTestCase(TestCase testCase, IndentLevel indendLevel) {
    StringBuilder sb = new StringBuilder();
    TestResult result = testCase.getResult();
    TestStatus status = result.getTestStatus();
    sb.append(indendLevel.get()).append(START_TESTCASE).append(SP_NAME_EQ).append(testCase.getName()).append(END_QUOTES).append(SP_CLASSNAME_EQ).append(testCase.getClassName()).append(END_QUOTES).append(SP_TIME_EQ).append(converTime(testCase.getResult().getElapsedTime())).append(END_QUOTES).append(END_NL);
    // add concrete data
    switch(status) {
        case PASSED:
            // no extra data
            break;
        case SKIPPED:
        case SKIPPED_NOT_IMPLEMENTED:
        case SKIPPED_PRECONDITION:
        case SKIPPED_IGNORE:
        case SKIPPED_FIXME:
            indendLevel.increase();
            sb.append(indendLevel.get()).append("<skipped/>\n");
            indendLevel.decrease();
            break;
        case FAILED:
        case ERROR:
            indendLevel.increase();
            sb.append(indendLevel.get()).append(START_ERROR).append(SP_MESSAGE_EQ).append(escapeString(testCase.getResult().getMessage())).append(END_QUOTES).append(END_NL);
            indendLevel.decrease();
            break;
        default:
            throw new RuntimeException("unhandled status " + status);
    }
    sb.append(indendLevel.get()).append(END_TESTCASE);
    return sb;
}
Also used : TestStatus(org.eclipse.n4js.tester.domain.TestStatus) TestResult(org.eclipse.n4js.tester.domain.TestResult)

Example 2 with TestStatus

use of org.eclipse.n4js.tester.domain.TestStatus in project n4js by eclipse.

the class TestEndedEventDispatcher method accept.

@Override
public void accept(TestEndedEvent tee) throws E {
    TestResult result = tee.getResult();
    TestStatus status = result.getTestStatus();
    switch(status) {
        case PASSED:
            passed.accept(tee);
            return;
        case SKIPPED:
            skipped.accept(tee);
            return;
        case SKIPPED_NOT_IMPLEMENTED:
            notimplemented.accept(tee);
            return;
        case SKIPPED_PRECONDITION:
            precondition.accept(tee);
            return;
        case SKIPPED_IGNORE:
            ignore.accept(tee);
            return;
        case SKIPPED_FIXME:
            fixmme.accept(tee);
            return;
        case FAILED:
            failed.accept(tee);
            return;
        case ERROR:
            error.accept(tee);
            return;
        default:
            unhandled.accept(tee);
    }
}
Also used : TestStatus(org.eclipse.n4js.tester.domain.TestStatus) TestResult(org.eclipse.n4js.tester.domain.TestResult)

Example 3 with TestStatus

use of org.eclipse.n4js.tester.domain.TestStatus in project n4js by eclipse.

the class TestProgressBar method onPaint.

/**
 * Paint.
 */
protected void onPaint(GC gc) {
    final Rectangle b = getBounds();
    final TestStatus status = counter != null ? counter.getAggregatedStatus() : null;
    if (status != null) {
        // this is our 100% value
        final int total = Math.max(expectedTotal, counter.getTotal());
        // current value
        final int value = counter.getTotal();
        final int totalPx = b.width;
        final int valuePx = Math.round(totalPx * (((float) value) / ((float) total)));
        gc.setBackground(getColorForStatus(status));
        gc.fillRectangle(0, 0, valuePx, b.height);
        gc.setBackground(getBackground());
        gc.fillRectangle(0 + valuePx, 0, b.width - valuePx, b.height);
    } else {
        // clear
        gc.setBackground(getBackground());
        gc.fillRectangle(b);
    }
    if (counter != null) {
        final FontMetrics fm = gc.getFontMetrics();
        gc.setForeground(getForeground());
        final int pending = expectedTotal > 0 ? expectedTotal - counter.getTotal() : -1;
        gc.drawString(counter.toString(true, pending, SWT.RIGHT), 4, b.height / 2 - fm.getHeight() / 2 - fm.getDescent(), true);
    }
}
Also used : TestStatus(org.eclipse.n4js.tester.domain.TestStatus) FontMetrics(org.eclipse.swt.graphics.FontMetrics) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point)

Example 4 with TestStatus

use of org.eclipse.n4js.tester.domain.TestStatus in project n4js by eclipse.

the class MockTest method createTestResult.

private Object createTestResult(final long timeout, final int i) {
    final String expected = valueOf(i);
    final String actual;
    final TestStatus status;
    if (0 == i % 19) {
        status = FAILED;
        actual = "mod 19 for " + i;
    } else if (0 == i % 31) {
        status = ERROR;
        actual = "mod 31 for " + i;
    } else if (highestOneBit(i) == i) {
        actual = "power of 2 for " + i;
        status = SKIPPED;
    } else {
        actual = expected;
        status = PASSED;
    }
    final TestResult result = new TestResult(status);
    result.setElapsedTime(timeout);
    result.setActual(actual);
    result.setExpected(expected);
    return result;
}
Also used : TestStatus(org.eclipse.n4js.tester.domain.TestStatus) TestResult(org.eclipse.n4js.tester.domain.TestResult)

Aggregations

TestStatus (org.eclipse.n4js.tester.domain.TestStatus)4 TestResult (org.eclipse.n4js.tester.domain.TestResult)3 FontMetrics (org.eclipse.swt.graphics.FontMetrics)1 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1