Package io.qameta.allure
Class AllureLifecycle
java.lang.Object
io.qameta.allure.AllureLifecycle
The class contains Allure context and methods to change it.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new lifecycle with default results writer.AllureLifecycle(AllureResultsWriter writer) Creates a new lifecycle instance with specifiedAllureResultsWriter. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachment(String name, String type, String fileExtension, byte[] body) Adds attachment into current test or step if any exists.voidaddAttachment(String name, String type, String fileExtension, InputStream stream) Adds attachment to current running test or step.Returns uuid of current running test case if any.Returns uuid of current running test case or step if any.prepareAttachment(String name, String type, String fileExtension) Adds attachment to current running test or step, and returns source.voidscheduleTestCase(io.qameta.allure.model.TestResult result) Schedule given test case.voidscheduleTestCase(String containerUuid, io.qameta.allure.model.TestResult result) Schedules test case with given parent.booleansetCurrentTestCase(String uuid) Sets specified test case uuid as current.voidstartPrepareFixture(String containerUuid, String uuid, io.qameta.allure.model.FixtureResult result) Start a new prepare fixture with given parent.voidStart a new step as child step of current running test case or step.voidStart a new step as child of specified parent.voidstartTearDownFixture(String containerUuid, String uuid, io.qameta.allure.model.FixtureResult result) Start a new tear down fixture with given parent.voidstartTestCase(String uuid) Starts test case with given uuid.voidstartTestContainer(io.qameta.allure.model.TestResultContainer container) Starts test container.voidstartTestContainer(String containerUuid, io.qameta.allure.model.TestResultContainer container) Starts test container with specified parent container.voidstopFixture(String uuid) Stops fixture by given uuid.voidstopStep()Stops current running step.voidStops step by given uuid.voidstopTestCase(String uuid) Stops test case by given uuid.voidstopTestContainer(String uuid) Stops test container by given uuid.voidupdateFixture(String uuid, Consumer<io.qameta.allure.model.FixtureResult> update) Updates fixture by given uuid.voidupdateFixture(Consumer<io.qameta.allure.model.FixtureResult> update) Updates current running fixture.voidupdateStep(String uuid, Consumer<io.qameta.allure.model.StepResult> update) Updates step by specified uuid.voidupdateStep(Consumer<io.qameta.allure.model.StepResult> update) Updates current step.voidupdateTestCase(String uuid, Consumer<io.qameta.allure.model.TestResult> update) Updates test case by given uuid.voidupdateTestCase(Consumer<io.qameta.allure.model.TestResult> update) Shortcut forupdateTestCase(String, Consumer)for current running test case uuid.voidupdateTestContainer(String uuid, Consumer<io.qameta.allure.model.TestResultContainer> update) Updates test container.voidwriteAttachment(String attachmentSource, InputStream stream) Writes attachment with specified source.voidwriteTestCase(String uuid) Writes test case with given uuid using configuredAllureResultsWriter.voidwriteTestContainer(String uuid) Writes test container with given uuid.
-
Constructor Details
-
AllureLifecycle
public AllureLifecycle()Creates a new lifecycle with default results writer. Shortcut forAllureLifecycle(AllureResultsWriter) -
AllureLifecycle
Creates a new lifecycle instance with specifiedAllureResultsWriter.- Parameters:
writer- the results writer.
-
-
Method Details
-
startTestContainer
public void startTestContainer(String containerUuid, io.qameta.allure.model.TestResultContainer container) Starts test container with specified parent container.- Parameters:
containerUuid- the uuid of parent container.container- the container.
-
startTestContainer
public void startTestContainer(io.qameta.allure.model.TestResultContainer container) Starts test container.- Parameters:
container- the container.
-
updateTestContainer
public void updateTestContainer(String uuid, Consumer<io.qameta.allure.model.TestResultContainer> update) Updates test container.- Parameters:
uuid- the uuid of container.update- the update function.
-
stopTestContainer
Stops test container by given uuid.- Parameters:
uuid- the uuid of container.
-
writeTestContainer
Writes test container with given uuid.- Parameters:
uuid- the uuid of container.
-
startPrepareFixture
public void startPrepareFixture(String containerUuid, String uuid, io.qameta.allure.model.FixtureResult result) Start a new prepare fixture with given parent.- Parameters:
containerUuid- the uuid of parent container.uuid- the fixture uuid.result- the fixture.
-
startTearDownFixture
public void startTearDownFixture(String containerUuid, String uuid, io.qameta.allure.model.FixtureResult result) Start a new tear down fixture with given parent.- Parameters:
containerUuid- the uuid of parent container.uuid- the fixture uuid.result- the fixture.
-
updateFixture
Updates current running fixture. Shortcut forupdateFixture(String, Consumer).- Parameters:
update- the update function.
-
updateFixture
Updates fixture by given uuid.- Parameters:
uuid- the uuid of fixture.update- the update function.
-
stopFixture
Stops fixture by given uuid.- Parameters:
uuid- the uuid of fixture.
-
getCurrentTestCase
Returns uuid of current running test case if any.- Returns:
- the uuid of current running test case.
-
getCurrentTestCaseOrStep
Returns uuid of current running test case or step if any.- Returns:
- the uuid of current running test case or step.
-
setCurrentTestCase
Sets specified test case uuid as current. Note that test case with such uuid should be created and existed in storage, otherwise method take no effect.- Parameters:
uuid- the uuid of test case.- Returns:
- true if current test case was configured successfully, false otherwise.
-
scheduleTestCase
Schedules test case with given parent.- Parameters:
containerUuid- the uuid of container.result- the test case to schedule.
-
scheduleTestCase
public void scheduleTestCase(io.qameta.allure.model.TestResult result) Schedule given test case.- Parameters:
result- the test case to schedule.
-
startTestCase
Starts test case with given uuid. In order to start test case it should be scheduled at first.- Parameters:
uuid- the uuid of test case to start.
-
updateTestCase
Shortcut forupdateTestCase(String, Consumer)for current running test case uuid.- Parameters:
update- the update function.
-
updateTestCase
Updates test case by given uuid.- Parameters:
uuid- the uuid of test case to update.update- the update function.
-
stopTestCase
Stops test case by given uuid. Test case marked asStage.FINISHEDand also stop timestamp is calculated. Result would be stored in memory untilwriteTestCase(String)method is called. Also stopped test case could be updated byupdateTestCase(String, Consumer)method.- Parameters:
uuid- the uuid of test case to stop.
-
writeTestCase
Writes test case with given uuid using configuredAllureResultsWriter.- Parameters:
uuid- the uuid of test case to write.
-
startStep
Start a new step as child step of current running test case or step. Shortcut forstartStep(String, String, StepResult).- Parameters:
uuid- the uuid of step.result- the step.
-
startStep
Start a new step as child of specified parent.- Parameters:
parentUuid- the uuid of parent test case or step.uuid- the uuid of step.result- the step.
-
updateStep
Updates current step. Shortcut forupdateStep(String, Consumer).- Parameters:
update- the update function.
-
updateStep
Updates step by specified uuid.- Parameters:
uuid- the uuid of step.update- the update function.
-
stopStep
public void stopStep()Stops current running step. Shortcut forstopStep(String). -
stopStep
Stops step by given uuid.- Parameters:
uuid- the uuid of step to stop.
-
addAttachment
Adds attachment into current test or step if any exists. Shortcut foraddAttachment(String, String, String, InputStream)- Parameters:
name- the name of attachmenttype- the content type of attachmentfileExtension- the attachment file extensionbody- attachment content
-
addAttachment
Adds attachment to current running test or step.- Parameters:
name- the name of attachmenttype- the content type of attachmentfileExtension- the attachment file extensionstream- attachment content
-
prepareAttachment
Adds attachment to current running test or step, and returns source. In order to store attachment content usewriteAttachment(String, InputStream)method.- Parameters:
name- the name of attachmenttype- the content type of attachmentfileExtension- the attachment file extension- Returns:
- the source of added attachment
-
writeAttachment
Writes attachment with specified source.- Parameters:
attachmentSource- the source of attachment.stream- the attachment content.
-