public class TestReportValidator extends AbstractTest
Test
implementation can be used to validate the
operation of a specific test. A typical use is to create
known error conditions and check that the input Test
reports these errors properly.
This test checks that a given test status (passed or not)
and a given error code is returned by a Test
.
A TestReportValidator
is built with the Test
to
run, the expected status (passed or failed) and the expected
error code. The TestReportValidator
will pass if the
expected values are produced by the TestReport
created by the associated Test
. Otherwise, it will
fail with one of two error codes:
+ if the status is not the one expected, then the
ERROR_UNEXPECTED_TEST_STATUS code is used.. The report
description will have two entries: ENTRY_KEY_EXPECTED_STATUS
and ENTRY_KEY_RECEIVED_STATUS, both of which are Strings.
+ if the status is the one expected, but if the error code
differs from the expected one, then the
ERROR_UNEXPECTED_ERROR_CODE code is used. The report
description will have two entries: ENTRY_KEY_EXPECTED_ERROR_CODE
and ENTRY_KEY_RECEIVED_ERROR_CODE.
Modifier and Type | Field and Description |
---|---|
static String |
ENTRY_KEY_EXPECTED_ERROR_CODE
The error description entry when the test fails
|
static String |
ENTRY_KEY_EXPECTED_STATUS
The entry describing the expected status when the test status
is unexpected.
|
static String |
ENTRY_KEY_RECEIVED_ERROR_CODE
Entry describing the received error code which is
different from the expected one.
|
static String |
ENTRY_KEY_RECEIVED_STATUS
Entry describing the received status which is
different from the expected one.
|
id, name, parent
Modifier | Constructor and Description |
---|---|
protected |
TestReportValidator()
Protected constructor, for use by derived classes
|
|
TestReportValidator(Test test,
boolean expectedStatus,
String expectedErrorCode)
Constructor
|
Modifier and Type | Method and Description |
---|---|
TestReport |
runImpl()
Subclasses should implement this method with the content of
the test case.
|
protected void |
setConfig(Test test,
boolean expectedStatus,
String expectedErrorCode)
Lets derived classes set the configuration parameters
for this test.
|
assertEquals, assertEquals, assertNull, assertTrue, error, getId, getName, getParent, getQualifiedId, reportError, reportException, reportSuccess, run, runImplBasic, setId, setName, setParent
public static final String ENTRY_KEY_EXPECTED_ERROR_CODE
public static final String ENTRY_KEY_RECEIVED_ERROR_CODE
public static final String ENTRY_KEY_EXPECTED_STATUS
public static final String ENTRY_KEY_RECEIVED_STATUS
public TestReportValidator(Test test, boolean expectedStatus, String expectedErrorCode)
protected TestReportValidator()
protected void setConfig(Test test, boolean expectedStatus, String expectedErrorCode)
public TestReport runImpl() throws Exception
AbstractTest
runImpl
in class AbstractTest
Exception
Copyright © 2000–2023 Apache Software Foundation. All rights reserved.