-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from TikhomirovSergey/0_20_25_ALPHA
0.20.25-ALPHA
- Loading branch information
Showing
131 changed files
with
2,078 additions
and
1,728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...re.integration/src/test/java/ru/tinkoff/qa/neptune/allure/AbstractAllurePreparations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ru.tinkoff.qa.neptune.allure; | ||
|
||
import io.qameta.allure.AllureLifecycle; | ||
import io.qameta.allure.internal.AllureStorage; | ||
import io.qameta.allure.model.TestResult; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
|
||
import java.util.UUID; | ||
|
||
import static io.qameta.allure.Allure.getLifecycle; | ||
import static java.util.UUID.randomUUID; | ||
|
||
public class AbstractAllurePreparations { | ||
|
||
final AllureLifecycle lifeCycle = getLifecycle(); | ||
final UUID testCaseUUID = randomUUID(); | ||
AllureStorage storage; | ||
|
||
private static AllureStorage getAllureStorage(AllureLifecycle lifecycle) throws Exception { | ||
var field = lifecycle.getClass().getDeclaredField("storage"); | ||
field.setAccessible(true); | ||
return (AllureStorage) field.get(lifecycle); | ||
} | ||
|
||
@BeforeClass | ||
public void beforeClass() throws Exception { | ||
storage = getAllureStorage(lifeCycle); | ||
storage.put(testCaseUUID.toString(), new TestResult()); | ||
lifeCycle.startTestCase(testCaseUUID.toString()); | ||
} | ||
|
||
@AfterClass | ||
public void afterClass() { | ||
lifeCycle.stopTestCase(testCaseUUID.toString()); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
allure.integration/src/test/java/ru/tinkoff/qa/neptune/allure/AttachmentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package ru.tinkoff.qa.neptune.allure; | ||
|
||
import io.qameta.allure.AllureResultsWriteException; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.image.BufferedImage; | ||
import java.nio.file.Paths; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.testng.Assert.fail; | ||
import static ru.tinkoff.qa.neptune.core.api.event.firing.StaticEventFiring.fireEventStarting; | ||
import static ru.tinkoff.qa.neptune.core.api.hamcrest.iterables.SetOfObjectsItemsMatcher.iterableHasItems; | ||
import static ru.tinkoff.qa.neptune.core.api.hamcrest.pojo.PojoGetterReturnsMatcher.getterReturns; | ||
|
||
public class AttachmentTest extends AbstractAllurePreparations { | ||
|
||
private String rootStepUUID; | ||
|
||
@BeforeClass | ||
public void prepareStep() { | ||
fireEventStarting("Some step", Map.of()); | ||
rootStepUUID = lifeCycle.getCurrentTestCaseOrStep().get(); | ||
} | ||
|
||
@Test | ||
public void textAttach() { | ||
new AllureStringInjector().inject(new StringBuilder("ABCD"), "String attach"); | ||
var step = storage.getStep(rootStepUUID).get(); | ||
assertThat(step.getAttachments(), | ||
iterableHasItems(1, | ||
getterReturns("getName", "String attach"), | ||
getterReturns("getSource", not(nullValue())), | ||
getterReturns("getType", "text/plain"))); | ||
} | ||
|
||
@Test | ||
public void imageAttach() throws Exception { | ||
var source = Paths.get("src/test/resources/picture.jpeg"); | ||
BufferedImage bi = ImageIO.read(source.toFile()); | ||
|
||
new AllureImageInjector().inject(bi, "Image attach"); | ||
var step = storage.getStep(rootStepUUID).get(); | ||
|
||
|
||
assertThat(step.getAttachments(), | ||
iterableHasItems(1, | ||
getterReturns("getName", "Image attach"), | ||
getterReturns("getSource", not(nullValue())), | ||
getterReturns("getType", "image/*"))); | ||
} | ||
|
||
@Test | ||
public void fileAttach() { | ||
var source = Paths.get("src/test/resources/test.json").toFile(); | ||
new AllureFileInjector().inject(source, "File attach"); | ||
|
||
var step = storage.getStep(rootStepUUID).get(); | ||
|
||
assertThat(step.getAttachments(), | ||
iterableHasItems(1, | ||
getterReturns("getName", "File attach"), | ||
getterReturns("getSource", not(nullValue())), | ||
getterReturns("getType", "application/json"))); | ||
} | ||
|
||
@Test(expectedExceptions = AllureResultsWriteException.class) | ||
public void fileAttach2() { | ||
var source = Paths.get("src/test/resources/not_existent").toFile(); | ||
new AllureFileInjector().inject(source, "File attach"); | ||
|
||
fail("Exception was expected"); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
allure.integration/src/test/java/ru/tinkoff/qa/neptune/allure/FailedStepLifeCycleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package ru.tinkoff.qa.neptune.allure; | ||
|
||
import io.qameta.allure.model.Status; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static io.qameta.allure.model.Status.BROKEN; | ||
import static io.qameta.allure.model.Status.FAILED; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
import static ru.tinkoff.qa.neptune.core.api.event.firing.StaticEventFiring.*; | ||
|
||
public class FailedStepLifeCycleTest extends AbstractAllurePreparations { | ||
|
||
@DataProvider | ||
public static Object[][] data1() { | ||
return new Object[][]{ | ||
{new AssertionError("Test assertion error"), FAILED}, | ||
{new RuntimeException(), BROKEN} | ||
}; | ||
} | ||
|
||
@Test(dataProvider = "data1") | ||
public void failedRootStep(Throwable thrown, Status expected) { | ||
fireEventStarting("Some step", Map.of()); | ||
var stepId = lifeCycle.getCurrentTestCaseOrStep().get(); | ||
var result = storage.getStep(stepId).get(); | ||
|
||
fireThrownException(thrown); | ||
fireEventFinishing(); | ||
assertThat(result.getStatus(), is(expected)); | ||
assertThat(result.getStop(), instanceOf(Long.class)); | ||
} | ||
|
||
@Test(dataProvider = "data1") | ||
public void failedNestedStep(Throwable thrown, Status expected) { | ||
fireEventStarting("Some root step", Map.of()); | ||
var rootStepId = lifeCycle.getCurrentTestCaseOrStep().get(); | ||
var rootResult = storage.getStep(rootStepId).get(); | ||
|
||
fireEventStarting("Some nested step", Map.of()); | ||
var nestedStepId = lifeCycle.getCurrentTestCaseOrStep().get(); | ||
var nestedResult = storage.getStep(nestedStepId).get(); | ||
|
||
fireThrownException(thrown); | ||
fireEventFinishing(); | ||
|
||
assertThat(rootResult.getStatus(), nullValue()); | ||
assertThat(rootResult.getStop(), nullValue()); | ||
|
||
assertThat(nestedResult.getStatus(), is(expected)); | ||
assertThat(nestedResult.getStop(), instanceOf(Long.class)); | ||
} | ||
|
||
@Test(priority = -1) | ||
public void failedWhenNoActiveStep() { | ||
fireThrownException(new AssertionError("Test assertion error")); | ||
assertThat(lifeCycle.getCurrentTestCaseOrStep().get(), is(testCaseUUID.toString())); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
allure.integration/src/test/java/ru/tinkoff/qa/neptune/allure/FakeTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.