Package com.aventstack.chaintest.domain
Class Test
java.lang.Object
com.aventstack.chaintest.domain.Test
- All Implemented Interfaces:
ChainTestEntity
Represents a test in the ChainTest framework.
This class contains information about the test such as its name, description,
class name, start and end times, result, tags, error details, and child tests.
It also provides methods to complete the test and update its statistics.
-
Constructor Summary
ConstructorsConstructorDescriptionTest()Default constructor.Constructs a Test with the specified build ID and method.Test(long buildId, Method method, Collection<String> tags) Constructs a Test with the specified build ID, method, and tags.Constructs a Test with the specified build ID and name.Test(long buildId, String name, Collection<String> tags) Constructs a Test with the specified build ID, name, and tags.Constructs a Test with the specified build ID, name, and optional class name.Constructs a Test with the specified build ID, name, optional class name, and tags.Constructs a Test with the specified build ID, name, optional class name, and tags.Constructs a Test with the specified build ID, name, and tags.Constructs a Test with the specified method.Test(Method method, Collection<String> tags) Constructs a Test with the specified method and tags.Constructs a Test with the specified name.Test(String name, Collection<String> tags) Constructs a Test with the specified name and tags.Constructs a Test with the specified name and optional class name.Constructs a Test with the specified name, optional class name, and tags.Constructs a Test with the specified name, optional class name, and tags.Constructs a Test with the specified name and tags. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidAdds an embedded media to the test from a byte array.voidAdds an embedded media to the test.voidAdds an embedded media to the test from a file.voidAdds an embedded media to the test.voidAdds a log entry to the test.voidvoidvoidaddTags(Collection<String> tags) voidcomplete()Completes the test with the current result.voidCompletes the test with the specified error.voidCompletes the test with the specified error.Returns the duration of the test in a human-readable format.voidsetEndedAt(Long endedAt) voidsetIsBdd(boolean isBDD) Sets whether the test is a BDD (Behavior-Driven Development) test.
-
Constructor Details
-
Test
public Test()Default constructor. -
Test
Constructs a Test with the specified build ID, name, optional class name, and tags.- Parameters:
buildId- the build IDname- the name of the testtestClass- the optional class name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified build ID, name, optional class name, and tags.- Parameters:
buildId- the build IDname- the name of the testtestClass- the optional class name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified name, optional class name, and tags.- Parameters:
name- the name of the testtestClass- the optional class name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified name, optional class name, and tags.- Parameters:
name- the name of the testtestClass- the optional class name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified build ID, name, and optional class name.- Parameters:
buildId- the build IDname- the name of the testtestClass- the optional class name of the test
-
Test
Constructs a Test with the specified name and optional class name.- Parameters:
name- the name of the testtestClass- the optional class name of the test
-
Test
Constructs a Test with the specified build ID, name, and tags.- Parameters:
buildId- the build IDname- the name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified build ID, name, and tags.- Parameters:
buildId- the build IDname- the name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified name and tags.- Parameters:
name- the name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified name and tags.- Parameters:
name- the name of the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified build ID and name.- Parameters:
buildId- the build IDname- the name of the test
-
Test
Constructs a Test with the specified name.- Parameters:
name- the name of the test
-
Test
Constructs a Test with the specified build ID, method, and tags.- Parameters:
buildId- the build IDmethod- the method representing the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified method and tags.- Parameters:
method- the method representing the testtags- the tags associated with the test
-
Test
Constructs a Test with the specified build ID and method.- Parameters:
buildId- the build IDmethod- the method representing the test
-
Test
Constructs a Test with the specified method.- Parameters:
method- the method representing the test
-
-
Method Details
-
complete
public void complete()Completes the test with the current result. -
complete
Completes the test with the specified error.- Parameters:
error- the optional error that occurred during the test
-
complete
Completes the test with the specified error.- Parameters:
error- the error that occurred during the test
-
setEndedAt
-
getDurationPretty
Returns the duration of the test in a human-readable format.- Returns:
- the duration of the test as a pretty string
-
addTags
-
addTag
-
addTag
-
addChild
-
addLog
Adds a log entry to the test.- Parameters:
log- the log entry to add
-
setIsBdd
public void setIsBdd(boolean isBDD) Sets whether the test is a BDD (Behavior-Driven Development) test.- Parameters:
isBDD- true if the test is a BDD test, false otherwise
-
addEmbed
Adds an embedded media to the test.- Parameters:
base64- the base64-encoded mediamediaType- the media type
-
addEmbed
Adds an embedded media to the test from a file.- Parameters:
file- the file containing the mediamediaType- the media type
-
addEmbed
Adds an embedded media to the test from a byte array.- Parameters:
bytes- the byte array containing the mediamediaType- the media type
-
addEmbed
Adds an embedded media to the test.- Parameters:
embed- the embedded media to add
-