From 0ced2253b9e390d98eff1ebbce5b3946b8335ff9 Mon Sep 17 00:00:00 2001 From: Suraj Deore Date: Tue, 10 Dec 2024 16:56:49 +0530 Subject: [PATCH] selenium system test into CI for html_report --- .github/workflows/ci.yml | 12 + Makefile | 4 + .../selenium-test/test_html_report.html | 386 ++++++++++++++++++ .../selenium-test/test_html_report.py | 59 +++ 4 files changed, 461 insertions(+) create mode 100644 tests-system/lobster-core/html_report/selenium-test/test_html_report.html create mode 100644 tests-system/lobster-core/html_report/selenium-test/test_html_report.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 607b3319..f3cc5712 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,18 @@ jobs: if: always() run: | util/check_local_modifications.sh + selenium-tests: + name: Run Selenium Tests + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install selenium webdriver-manager + - name: Run selenium Tests + run: | + make selenium-tests integration-tests: name: Integration tests needs: test diff --git a/Makefile b/Makefile index 9bf253bb..93fcd986 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,10 @@ clang-tidy: cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra' -DCMAKE_BUILD_TYPE=Release && \ cmake --build build --target clang-tidy +selenium-tests: + @echo "Running Selenium Tests..." + python3 ./tests-system/lobster-core/html_report/selenium-test/test_html_report.py + integration-tests: packages (cd tests-integration/projects/basic; make) (cd tests-integration/projects/filter; make) diff --git a/tests-system/lobster-core/html_report/selenium-test/test_html_report.html b/tests-system/lobster-core/html_report/selenium-test/test_html_report.html new file mode 100644 index 00000000..50050301 --- /dev/null +++ b/tests-system/lobster-core/html_report/selenium-test/test_html_report.html @@ -0,0 +1,386 @@ + + + +L.O.B.S.T.E.R. + + + +
+

L.O.B.S.T.E.R.

+
Lightweight Open BMW Software Traceability Evidence Report
+
+ +
+

Overview

+
+
+
+

Coverage

+ + + + + + + + + + + + + + + + + + + + + + + + +
CategoryRatioCoverageOK ItemsTotal Items
Requirements0.0% + +0.00% + +03
code0.0% + +0.00% + +03
+
+
+
+

Issues

+
+ +
+

Detailed report

+
+

Requirements and Specification

+

Requirements

+
.\main.trlc
+ +
+
TRLC Requirement vanillaEg.trlc
+
Source: + +.\main.trlc +
+
+
Treat Requirements Like Code
+
+
+
Issues: +
    +
  • missing reference to code
  • +
+
+
+
+ + +
+
TRLC Requirement vanillaEg.lobster
+
Source: + +.\main.trlc +
+
+
Lightweight Open BMW Software Traceability Evidence Report
+
+
+
Issues: +
    +
  • missing reference to code
  • +
+
+
+
+ +
Codebeamer https://codebeamer.company.net/, tracker 65426
+ +
+
codebeamer Technical requirement traffic light detection
+ +
+Status: Valid +
+
+
Issues: +
    +
  • missing reference to code
  • +
+
+
+
+ +

Implementation

+

code

+
.\Test_Setup\main.py
+ +
+
Python Function main.greet_user
+ +
+
Issues: +
    +
  • unknown tracing target req welcome.greet
  • +
  • missing up reference
  • +
+
+
+
+ +
.\software.py
+ +
+
Python Function software.hello
+
Source: + +.\software.py +
+
+
Issues: +
    +
  • missing up reference
  • +
+
+
+
+ + +
+
Python Function software.hello1
+
Source: + +.\software.py +
+
+
Issues: +
    +
  • missing up reference
  • +
+
+
+
+ +

Verification and Validation

+
+
+ + + diff --git a/tests-system/lobster-core/html_report/selenium-test/test_html_report.py b/tests-system/lobster-core/html_report/selenium-test/test_html_report.py new file mode 100644 index 00000000..7504b861 --- /dev/null +++ b/tests-system/lobster-core/html_report/selenium-test/test_html_report.py @@ -0,0 +1,59 @@ +import os +import sys +from selenium import webdriver +from selenium.webdriver.chrome.service import Service +from webdriver_manager.chrome import ChromeDriverManager +from selenium.webdriver.chrome.options import Options + +def test_html_report_title(dynamic_dir, report_filename, expected_title): + """ + Test function to verify the title of an HTML report with dynamic file path. + + Parameters: + - dynamic_dir (str): Base directory containing the report. + - report_filename (str): Name of the HTML report file. + - expected_title (str): Expected title of the report. + + Returns: + - bool: True if the title matches, False otherwise. + """ + dir_path = os.path.dirname(os.path.abspath(__file__)) + + file_path = dir_path + "/test_html_report.html" + + report_path = os.path.join(dynamic_dir, report_filename) + file_url = f"file:///{os.path.abspath(report_path)}" + + # Headless mode options + chrome_options = Options() + chrome_options.add_argument("--headless") + chrome_options.add_argument("--no-sandbox") + chrome_options.add_argument("--disable-dev-shm-usage") + # Automatically download ChromeDriver + driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) + try: + driver.get(file_url) + actual_title = driver.title + if actual_title == expected_title: + print(f"Test Passed: Title is '{actual_title}'") + sys.exit(0) + else: + print(f"Test Failed: Expected '{expected_title}', but got '{actual_title}'") + sys.exit(1) + + except Exception as e: + print(f"Error: {e}") + sys.exit(1) + return False + + finally: + driver.quit() + +if __name__ == "__main__": + + base_directory = "./tests-system/lobster-core/html_report/selenium-test" + report_file = "test_html_report.html" + expected_title = 'L.O.B.S.T.E.' + sys.exit(test_html_report_title(base_directory, report_file, expected_title)) + +