io.qameta.allure.Step Java Examples

The following examples show how to use io.qameta.allure.Step. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllureCitrusTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Step("Run test case {testDesigner}")
private AllureResults run(final TestDesigner testDesigner) {
    final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(
            CitrusSpringConfig.class, AllureCitrusConfig.class
    );
    final Citrus citrus = Citrus.newInstance(applicationContext);
    final TestContext testContext = citrus.createTestContext();

    final TestActionListeners listeners = applicationContext.getBean(TestActionListeners.class);
    final AllureLifecycle defaultLifecycle = Allure.getLifecycle();
    final AllureLifecycle lifecycle = applicationContext.getBean(AllureLifecycle.class);
    try {
        Allure.setLifecycle(lifecycle);
        final TestCase testCase = testDesigner.getTestCase();
        testCase.setTestActionListeners(listeners);

        citrus.run(testCase, testContext);
    } catch (Exception ignored) {
    } finally {
        Allure.setLifecycle(defaultLifecycle);
    }

    return applicationContext.getBean(AllureResultsWriterStub.class);
}
 
Example #2
Source File: AllureJunit4Test.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Step("Run classes {classes}")
private AllureResults runClasses(final Class<?>... classes) {
    final AllureResultsWriterStub writerStub = new AllureResultsWriterStub();
    final AllureLifecycle lifecycle = new AllureLifecycle(writerStub);
    final JUnitCore core = new JUnitCore();
    core.addListener(new AllureJunit4(lifecycle));

    final AllureLifecycle defaultLifecycle = Allure.getLifecycle();
    try {
        Allure.setLifecycle(lifecycle);
        StepsAspects.setLifecycle(lifecycle);
        AttachmentsAspects.setLifecycle(lifecycle);
        core.run(classes);
        return writerStub;
    } finally {
        Allure.setLifecycle(defaultLifecycle);
        StepsAspects.setLifecycle(defaultLifecycle);
        AttachmentsAspects.setLifecycle(defaultLifecycle);
    }
}
 
Example #3
Source File: MongoDBArtifactStoreTest.java    From hawkbit-extensions with Eclipse Public License 1.0 6 votes vote down vote up
@Step
private String storeRandomArtifactAndVerify(final String tenant) throws NoSuchAlgorithmException, IOException {
    final int filelengthBytes = 128;
    final String filename = "testfile.json";
    final MessageDigest mdSHA1 = MessageDigest.getInstance("SHA1");
    final MessageDigest mdMD5 = MessageDigest.getInstance("MD5");

    storeArtifact(tenant, filename, generateInputStream(filelengthBytes), mdSHA1, mdMD5, null);

    final String sha1Hash16 = BaseEncoding.base16().lowerCase().encode(mdSHA1.digest());
    final String md5Hash16 = BaseEncoding.base16().lowerCase().encode(mdMD5.digest());

    final AbstractDbArtifact loaded = artifactStoreUnderTest.getArtifactBySha1(tenant, sha1Hash16);
    assertThat(loaded).isNotNull();
    assertThat(loaded.getContentType()).isEqualTo("application/json");
    assertThat(loaded.getHashes().getSha1()).isEqualTo(sha1Hash16);
    assertThat(loaded.getHashes().getMd5()).isEqualTo(md5Hash16);
    assertThat(loaded.getSize()).isEqualTo(filelengthBytes);

    return sha1Hash16;
}
 
Example #4
Source File: LogIn.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Logging in to AEM")
public void execute() {
  webDriver.get(authorUrl + "/libs/granite/core/content/login.html");
  webDriver.manage()
      .addCookie(aemAuthCookieFactory.getCookie(authorUrl, authorLoginProperty, authorPassword));
}
 
Example #5
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Step("Check after fixtures")
private static void assertAfterFixtures(String containerName, List<TestResultContainer> containers,
                                        Object... afters) {
    assertThat(containers)
            .filteredOn(container -> container.getName().equals(containerName))
            .as("After fixtures are not attached to container " + containerName)
            .flatExtracting(TestResultContainer::getAfters)
            .is(ALL_FINISHED)
            .is(WITH_STEPS)
            .flatExtracting(FixtureResult::getName)
            .containsExactly(afters);
}
 
Example #6
Source File: CreatePage.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Create test page {data.contentPath}")
public void execute(SlingPageData data) throws AemPageManipulationException {
  HttpPost request = new HttpPost(authorIP + data.getContentPath());
  request.setEntity(new UrlEncodedFormEntity(data.getContent(), Consts.UTF_8));
  try {
    httpClient.execute(request);
  } catch (IOException e) {
    throw new AemPageManipulationException(e);
  } finally {
    request.releaseConnection();
  }
}
 
Example #7
Source File: CreatePageWizardImpl.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Submit page for creation")
public void submit() {
  wait.until(input -> getCreateButton().isEnabled());
  getCreateButton().click();
  List<WebElement> elements =
      pageCreatedModal.findElements(By.xpath("//coral-button-label[contains(text(),'Done')]"));

  elements.stream()
      .findFirst()
      .orElseThrow(() -> new NoSuchElementException("\"Done\" button not found"))
      .click();
}
 
Example #8
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Step("Find results by name")
private TestResult findTestResultByName(final AllureResults results, final String name) {
    return results.getTestResults().stream()
            .filter(testResult -> name.equalsIgnoreCase(testResult.getName()))
            .findFirst()
            .orElseThrow(() -> new IllegalStateException("can not find result by name " + name));
}
 
Example #9
Source File: EditComponent.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Edit component")
public void execute(ComponentData data) {
  sidePanel.selectTab(SidePanelTabs.CONTENT_TREE.getCssClass());
  sidePanel.selectComponentToEdit(data.getComponentPath(), data.getComponentName(),
      data.getComponentOrder()).click();
  componentToolbar.clickOption(CommonToolbarOptions.EDIT.getTitle());
}
 
Example #10
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Step("Check containers children")
private static void assertContainersChildren(String name, List<TestResultContainer> containers, List<String> uids) {
    assertThat(containers)
            .filteredOn("name", name)
            .flatExtracting(TestResultContainer::getChildren)
            .as("Unexpected children for testng container " + name)
            .containsOnlyElementsOf(uids);
}
 
Example #11
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Step("Check containers per method")
private static void assertContainersPerMethod(String name, List<TestResultContainer> containersList,
                                              List<String> uids) {
    final Condition<List<? extends TestResultContainer>> singlyMapped = new Condition<>(containers ->
            containers.stream().allMatch(c -> c.getChildren().size() == 1),
            format("All containers for per-method fixture %s should be linked to only one testng result", name));

    assertThat(containersList)
            .filteredOn("name", name)
            .is(singlyMapped)
            .flatExtracting(TestResultContainer::getChildren)
            .as("Unexpected children for per-method fixtures " + name)
            .containsOnlyElementsOf(uids);
}
 
Example #12
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Step("Find container by name")
private TestResultContainer findTestContainerByName(final AllureResults results, final String name) {
    return results.getTestResultContainers().stream()
            .filter(testResultContainer -> name.equalsIgnoreCase(testResultContainer.getName()))
            .findFirst()
            .orElseThrow(() -> new IllegalStateException("can not find container by name " + name));
}
 
Example #13
Source File: AllureJunit5Test.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Step("Run classes {classes}")
private AllureResults runClasses(final Class<?>... classes) {
    final AllureResultsWriterStub writerStub = new AllureResultsWriterStub();
    final AllureLifecycle lifecycle = new AllureLifecycle(writerStub);

    final ClassSelector[] classSelectors = Stream.of(classes)
            .map(DiscoverySelectors::selectClass)
            .toArray(ClassSelector[]::new);

    final LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
            .configurationParameter("junit.jupiter.extensions.autodetection.enabled", "true")
            .selectors(classSelectors)
            .build();

    final LauncherConfig config = LauncherConfig.builder()
            .enableTestExecutionListenerAutoRegistration(false)
            .addTestExecutionListeners(new AllureJunitPlatform(lifecycle))
            .build();
    final Launcher launcher = LauncherFactory.create(config);

    final AllureLifecycle defaultLifecycle = Allure.getLifecycle();
    try {
        Allure.setLifecycle(lifecycle);
        StepsAspects.setLifecycle(lifecycle);
        AttachmentsAspects.setLifecycle(lifecycle);
        launcher.execute(request);
        return writerStub;
    } finally {
        Allure.setLifecycle(defaultLifecycle);
        StepsAspects.setLifecycle(defaultLifecycle);
        AttachmentsAspects.setLifecycle(defaultLifecycle);
    }
}
 
Example #14
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Step("Check before fixtures")
private static void assertBeforeFixtures(String containerName, List<TestResultContainer> containers,
                                         Object... befores) {
    assertThat(containers)
            .filteredOn(container -> container.getName().equals(containerName))
            .as("Before fixtures are not attached to container " + containerName)
            .flatExtracting(TestResultContainer::getBefores)
            .is(ALL_FINISHED)
            .is(WITH_STEPS)
            .flatExtracting(FixtureResult::getName)
            .containsExactly(befores);
}
 
Example #15
Source File: AllureTestNgTest.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Step("Check that javadoc description of tests refer to correct test methods")
private static void checkTestJavadocDescriptions(List<TestResult> results, String methodReference, String expectedDescriptionHtml) {
    assertThat(results).as("Test results has not been written")
            .isNotEmpty()
            .filteredOn(result -> result.getFullName().equals(methodReference))
            .extracting(result -> result.getDescriptionHtml().trim())
            .as("Javadoc description of befores have been processed incorrectly")
            .containsOnly(expectedDescriptionHtml);
}
 
Example #16
Source File: StepsAspects.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Before("anyMethod() && withStepAnnotation()")
public void stepStart(final JoinPoint joinPoint) {
    final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    final Step step = methodSignature.getMethod().getAnnotation(Step.class);

    final String uuid = UUID.randomUUID().toString();
    final String name = getName(step.value(), joinPoint);
    final List<Parameter> parameters = getParameters(methodSignature, joinPoint.getArgs());

    final StepResult result = new StepResult()
            .setName(name)
            .setParameters(parameters);

    getLifecycle().startStep(uuid, result);
}
 
Example #17
Source File: MapStepDefs.java    From frameworkium-bdd with Apache License 2.0 5 votes vote down vote up
@Step
@Then("^I should see information about \"([^\"]*)\"$")
public void i_should_see_information_about(String searchTerm) {
    MapInfoPane mapInfoPaneWithTimeout =
            new MapInfoPane().get(Duration.ofSeconds(30));
    assertThat(mapInfoPaneWithTimeout.getInfoHeaderText())
            .contains(searchTerm);
}
 
Example #18
Source File: ConfigureComponent.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@Step("Configure component")
public void execute(ConfigureComponentData data) {
  selectComponent(data);
  componentToolbar.clickOption(CommonToolbarOptions.CONFIGURE.getTitle());
  ComponentConfiguration componentConfiguration =
      componentConfigReader.readConfiguration(data.getConfigLocation());
  configDialog.configureWith(componentConfiguration);
}
 
Example #19
Source File: CreatePageWizardImpl.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Select template {templateName}")
public CreatePageWizard selectTemplate(String templateName) {
  templateList.selectTemplate(templateName);
  getNextButton().click();
  return this;
}
 
Example #20
Source File: EditComponent.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Edit component")
public void execute(ComponentData data) {
  sidePanel.selectTab(SidePanelTabs.CONTENT_TREE.getCssClass());
  sidePanel.selectComponentToEdit(data.getComponentPath(), data.getComponentName(),
      data.getComponentOrder()).click();
  componentToolbar.clickOption(CommonToolbarOptions.EDIT.getTitle());
}
 
Example #21
Source File: AemAuthorPage.java    From bobcat with Apache License 2.0 5 votes vote down vote up
/**
 * Open the page in browser
 */
@Step("Open page")
@Override
public T open() {
  webDriver.get(authorUrl + getFullUrl());
  return (T) this;
}
 
Example #22
Source File: CreatePage.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@Override
@Step("Create test page {data.contentPath}")
public void execute(SlingPageData data) throws AemPageManipulationException {
  HttpPost request = new HttpPost(authorIP + data.getContentPath());
  request.setEntity(new UrlEncodedFormEntity(data.getContent(), Consts.UTF_8));
  try {
    httpClient.execute(request);
  } catch (IOException e) {
    throw new AemPageManipulationException(e);
  }
}
 
Example #23
Source File: ConfigureComponent.java    From bobcat with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@Step("Configure component")
public void execute(ConfigureComponentData data) {
  selectComponent(data);
  componentToolbar.clickOption(CommonToolbarOptions.CONFIGURE.getTitle());
  ComponentConfiguration componentConfiguration =
      componentConfigReader.readConfiguration(data.getConfigLocation());
  configDialog.configureWith(componentConfiguration);
}
 
Example #24
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Step("use {method}")
void stepWithMethodParameter(final String method) {
}
 
Example #25
Source File: LogOut.java    From bobcat with Apache License 2.0 4 votes vote down vote up
@Override
@Step("Logging out of AEM")
public void execute() {
  webDriver.get(authorUrl + "/system/sling/logout.html");
  aemAuthCookieFactory.removeCookie(authorUrl);
}
 
Example #26
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Step("\"{user.emails.address}\", \"{user.emails}\", \"{user.emails.attachments}\", \"{user.password}\", \"{}\"," +
        " \"{user.card.number}\", \"{missing}\", {staySignedIn}")
private void loginWith(final DummyUser user, final boolean staySignedIn) {
}
 
Example #27
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Step
void stepWithParams(final String a, final String b) {
}
 
Example #28
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Step("TestData = {value}")
public void checkData(@SuppressWarnings("unused") final String value) {
}
 
Example #29
Source File: SeleniumHQStepDefs.java    From frameworkium-bdd with Apache License 2.0 4 votes vote down vote up
@Step
@When("^I click downloads$")
public void i_click_downloads() {
    new SeleniumHomePage().get().gotoDownloadsPage();
}
 
Example #30
Source File: StepsAspectsTest.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Step
void stepWithAssertion() {
    throw new AssertionError("some assertion");
}