public class FreeSpec extends FreeSpecBase implements LambdaTest
Inherit from this class to create a new TestNG test suite and use the
test(java.lang.String, de.tobiasroeser.lambdatest.RunnableWithException)
method to add test cases.
It provides the following methods:
test(String, RunnableWithException)
to declare a new test
case
FreeSpecBase.intercept(Class, RunnableWithException)
and
FreeSpecBase.intercept(Class, String, RunnableWithException)
to intercept
and assert expected exceptions.
FreeSpecBase.pending()
to mark a test case as pending. All code before
it’s usage including asserts will be executed, but code after it will be
skipped. Thus you can mark a test also as work-in-progress.
TODO: example
FreeSpecBase.F0WithException<R>
Constructor and Description |
---|
FreeSpec() |
Modifier and Type | Method and Description |
---|---|
Iterator<Object[]> |
freeSpecParallelTestCases() |
Iterator<Object[]> |
freeSpecTestCases() |
void |
pending(String reason)
Marks the test as pending and uses the given
reason as
message. |
void |
runFreeSpecParallelTestCases(DefaultTestCase testCase) |
void |
runFreeSpecTestCases(DefaultTestCase testCase) |
void |
setExpectFailFast(boolean failFast)
If
true , the first failed assertion will also fail the test. |
void |
setRunInParallel(boolean runInParallel)
If
true tests in this suite can be run in parallel. |
void |
test(String name,
RunnableWithException testCase)
Adds a test to the test suite.
|
getCurrentSection, getDefaultReporter, getExpectFailFast, getReporter, getRunInParallel, getSuiteName, getTestCases, intercept, intercept, pending, section, setDefaultReporter, setReporter, withDefaultReporter
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getReporter, intercept, intercept, pending, setReporter
public void setRunInParallel(boolean runInParallel)
LambdaTest
If true
tests in this suite can be run in parallel.
setRunInParallel
in interface LambdaTest
setRunInParallel
in class FreeSpecBase
runInParallel
- If true
, tests may execute in parallel.public void setExpectFailFast(boolean failFast)
LambdaTest
If true
, the first failed assertion will also fail the test. If
false
, the test runs as long as possible, potentially collection
multipe failed assertions.
setExpectFailFast
in interface LambdaTest
setExpectFailFast
in class FreeSpecBase
failFast
- If true
, to fail fast.public void test(String name, RunnableWithException testCase)
Adds a test to the test suite.
test
in class FreeSpecBase
name
- The name of the new test.testCase
- The test case. It should return when it is successful, else it
should throw an exception. Exceptions of type
TestException
which are typically thrown by
Assert.assertXXX methods (e.g.
Assert.assertEquals(String, String)
) are specially
recognized by TestNG.public void pending(String reason)
Marks the test as pending and uses the given reason
as
message. Instructions after pending()
will not be executed
and TestNG marks the test as skipped.
pending
in interface LambdaTest
public void runFreeSpecTestCases(DefaultTestCase testCase) throws Throwable
Throwable
public void runFreeSpecParallelTestCases(DefaultTestCase testCase) throws Throwable
Throwable
Copyright © 2019. All rights reserved.