From b3ebf91e310cb4eecf4b90a4f95905aece94649c Mon Sep 17 00:00:00 2001 From: Roman Burlaka Date: Wed, 8 Oct 2025 21:42:15 +0200 Subject: [PATCH 1/2] added allure, ci.yaml, gh-pages --- .github/workflows/ci.yaml | 95 +++++++++++++++---- .gitignore | 1 + .idea/workspace.xml | 42 ++++---- pom.xml | 42 ++++++++ .../java/automatiom/tests/ElementsPage.java | 6 +- .../tests/tests/ElementsPageTest.java | 10 +- src/test/resources/allure.properties | 1 + 7 files changed, 159 insertions(+), 38 deletions(-) create mode 100644 src/test/resources/allure.properties diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 025db33..e325488 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,35 +1,96 @@ -name: CI +name: Java CI with Maven on: pull_request: - branches: [main] + branches: + - main + push: + branches: + - main jobs: - run-test: + build: name: 'Run tests' runs-on: ubuntu-latest steps: + # 1. Cloning - name: Git clone - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - - name: Install JDK - uses: actions/setup-java@v3 + # 2. Install Java 17 + - name: Setup JDK 17 + uses: actions/setup-java@v4 with: - distribution: 'corretto' java-version: '17' + distribution: 'corretto' cache: 'maven' - - name: Get list of changed files - run: echo "LIST_OF_CHANGED_FILES=$(git diff --name-only origin/$GITHUB_HEAD_REF $(git merge-base origin/$GITHUB_HEAD_REF origin/main) | tr '\n' ';')" >> $GITHUB_ENV + # 3. Run tests (not stop workflow if failure ) + - name: Build and run tests with Maven + run: mvn -B -e clean test -Dselenium.headless=true || true + env: + CHROME_OPTIONS: --remote-allow-origins=*;--disable-gpu;--no-sandbox;--disable-dev-shm-usage;--headless=new;--window-size=1920,1080 - - name: Attach screenshots and reports - uses: actions/upload-artifact@v3 + # 4. Output failed tests + - name: Print failed tests if: failure() + run: | + echo "---- TEST FAILURES ----" + cat target/surefire-reports/*.txt || true + + # 5. Attach screenshots + - name: Attach screenshots + if: always() + uses: actions/upload-artifact@v4 + with: + name: screenshots + path: ${{ github.workspace }}/screenshots + + # 6. Get Allure (gh-pages) + - name: Get Allure history + uses: actions/checkout@v4 + if: always() + continue-on-error: true + with: + ref: gh-pages + path: gh-pages + + # 7. Build Allure report + - name: Build Allure report + uses: simple-elf/allure-report-action@master + if: always() + id: allure-report + with: + allure_results: target/allure-results + gh_pages: gh-pages + allure_report: allure-report + allure_history: allure-history + + # 8. Upload Allure report artifact + - name: Upload Allure report artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: allure-report + path: target/allure-report + + # 9. Check allure-results + - name: Check Allure results + run: ls -la target/allure-results + + # 10. Publish Allure to GitHub Pages + - name: Publish Allure report to Github Pages + if: always() + uses: peaceiris/actions-gh-pages@v2 + env: + PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PUBLISH_BRANCH: gh-pages + PUBLISH_DIR: allure-history + + - name: Upload Allure HTML report as artifact + if: always() + uses: actions/upload-artifact@v4 with: - name: screenshots-and-report - path: | - screenshots - target/surefire-reports/emailable-report.html \ No newline at end of file + name: allure-report + path: allure-report \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ff6309..ffe7f4b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ target/ *.iws *.iml *.ipr +'.idea/workspace.xml ### Eclipse ### .apt_generated diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 11e489f..b5485ec 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,12 @@ + + - - - - - + + + - { + "lastFilter": { + "state": "OPEN", + "assignee": "RomanBurlaka78" } -}]]> - + { + "selectedUrlAndAccountId": { + "url": "https://github.com/RomanBurlaka78/DemoqaJava-.git", + "accountId": "bc05234d-3816-4ee0-9a85-a3a7ea48eb65" } -}]]> +} @@ -61,6 +61,7 @@ "Maven.szablon_javaTest [test].executor": "Run", "RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true", "RunOnceActivity.git.unshallow": "true", "TestNG.ElementsPageTest.testGoToElementsPage.executor": "Run", "TestNG.ElementsPageTests.executor": "Run", @@ -69,12 +70,18 @@ "TestNG.ElementsPageTests.testVerifyTextBox (1).executor": "Run", "TestNG.ElementsPageTests.testVerifyTextBox.executor": "Run", "TestNG.ElementsPageTests.testVerifyTextBoxForm.executor": "Run", - "git-widget-placeholder": "main", + "git-widget-placeholder": "test", "ignore.virus.scanning.warn.message": "true", "kotlin-language-version-configured": "true", - "last_opened_file_path": "C:/Disk D/RedRover.shools/automationExercise_java" + "last_opened_file_path": "C:/Disk D/RedRover.shools/automationExercise_java", + "settings.editor.selected.configurable": "terminal" } }]]> + + + + + @@ -168,7 +175,6 @@ - diff --git a/pom.xml b/pom.xml index 0231900..7b28358 100644 --- a/pom.xml +++ b/pom.xml @@ -12,9 +12,22 @@ 17 17 + 2.24.0 + 1.9.20.1 UTF-8 + + + + io.qameta.allure + allure-bom + ${allure.version} + pom + import + + + @@ -35,8 +48,37 @@ test + + io.qameta.allure + allure-testng + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" + + + + + org.aspectj + aspectjweaver + + 1.9.22 + + + + + + diff --git a/src/test/java/automatiom/tests/ElementsPage.java b/src/test/java/automatiom/tests/ElementsPage.java index 611a1ad..f6d31ab 100644 --- a/src/test/java/automatiom/tests/ElementsPage.java +++ b/src/test/java/automatiom/tests/ElementsPage.java @@ -2,6 +2,7 @@ import automatiom.tests.base.BaseConfigurationPage; import automatiom.tests.base.BasePage; +import io.qameta.allure.Step; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -25,7 +26,7 @@ public ElementsTextBoxPage clickGotoNewPage() { } - @FindBy(xpath ="//div[@class = 'accordion']//div[@class='element-group'][1]") + @FindBy(xpath = "//div[@class = 'accordion']//div[@class='element-group'][1]") WebElement sectionElements; @FindBy(xpath = "//span[contains(text(), 'Text Box')]") @@ -36,6 +37,7 @@ public String getUrlOfPage() { return getDriver().getCurrentUrl(); } + @Step("Show elements content") public ElementsPage showElementsContent() { sectionElements.click(); getDriver().navigate().back(); @@ -44,11 +46,11 @@ public ElementsPage showElementsContent() { return this; } + @Step("Show text box") public ElementsTextBoxPage showTextBoxText() { getTextBox.click(); return new ElementsTextBoxPage(getDriver()); } - } diff --git a/src/test/java/automatiom/tests/tests/ElementsPageTest.java b/src/test/java/automatiom/tests/tests/ElementsPageTest.java index 7fee99d..8dc57ed 100644 --- a/src/test/java/automatiom/tests/tests/ElementsPageTest.java +++ b/src/test/java/automatiom/tests/tests/ElementsPageTest.java @@ -4,9 +4,15 @@ import automatiom.tests.ElementsTextBoxPage; import automatiom.tests.HomePage; import automatiom.tests.runner.BaseTest; +import io.qameta.allure.Epic; +import io.qameta.allure.Feature; +import io.qameta.allure.Story; import org.testng.Assert; import org.testng.annotations.Test; +@Epic("Selenium elements") +@Feature("Elements") + public class ElementsPageTest extends BaseTest { private static final String ELEMENTS_PAGE = "https://demoqa.com/elements"; @@ -19,7 +25,7 @@ public class ElementsPageTest extends BaseTest { private ElementsTextBoxPage titleOfTextBoxElementsPage; - @Test() + @Test public void testGetTitle() { String homePage = new HomePage(getDriver()) .accetpCookies() @@ -44,6 +50,7 @@ public void testGoToElementsPage() { @Test + @Story("Text box") public void testVerifyTextBox() { String titleOfTextBoxElementsPage = new HomePage(getDriver()) .accetpCookies() @@ -58,6 +65,7 @@ public void testVerifyTextBox() { } @Test + @Story("Text box") public void testVerifyTextBoxForm() { String titleOfTextBoxElementsPage = new HomePage(getDriver()) .accetpCookies() diff --git a/src/test/resources/allure.properties b/src/test/resources/allure.properties new file mode 100644 index 0000000..6c1e0bb --- /dev/null +++ b/src/test/resources/allure.properties @@ -0,0 +1 @@ +allure.results.directory=target/allure-results \ No newline at end of file From dca1714d62b7e46b0da82f317443ee0a2c9ffcdb Mon Sep 17 00:00:00 2001 From: Roman Burlaka Date: Wed, 8 Oct 2025 21:50:38 +0200 Subject: [PATCH 2/2] added allure, ci.yaml, gh-pages --- .idea/workspace.xml | 4 ---- pom.xml | 13 +++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b5485ec..223753f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,8 @@ - - - -