Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
test-report-generator
Advanced tools
The test_report_generator
library is designed to facilitate the creation of automated test reports. It provides decorators for defining steps, test cases, scenarios, and generating reports.
To install the test_report_generator
library, use the following command:
pip install test_report_generator
The library includes several decorators to enhance your test cases and generate detailed reports.
Here's an example of how to use the test_report library with unittest:
import unittest
from test_report import *
@Step(name="First step", description="This is the first step in the test case.")
def first_step():
pass
@Step(name="Second step", description="This is the second step in the test case.")
def second_step():
pass
@Step(name="Third step", description="This is the third step in the test case.", get_screenshot=True)
def third_step():
raise AssertionError("Force the test to fail.")
@TestCase(name="First test case")
def first_test_case():
first_step()
second_step()
@TestCase(name="Second test case")
def second_test_case():
first_step()
second_step()
@TestCase(name="Third test case")
def third_test_case():
first_step()
second_step()
third_step()
class Tests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
pass
@classmethod
@GenerateReport
def tearDownClass(cls) -> None:
pass
@Scenario(name="First scenario")
def test_first_scenario(self):
first_test_case()
@Scenario(name="Second scenario")
def test_second_scenario(self):
first_test_case()
second_test_case()
@Scenario(name="Third scenario")
def test_third_scenario(self):
first_test_case()
second_test_case()
third_test_case()
if __name__ == '__main__':
unittest.main()
Steps: Define the individual steps of your test cases using the @Step
decorator.
@Step(name="Step Name", description="Step Description", get_screenshot=True)
def step_function():
# Step implementation
pass
Test Cases: Combine steps into test cases using the @TestCase decorator.
@TestCase(name="Test Case Name")
def test_case_function():
step_function()
Scenarios: Group test cases into scenarios using the @Scenario decorator.
@Scenario(name="Scenario Name")
def scenario_method(self):
test_case_function()
Generate Report: Automatically generate a test report after executing the test suite by using the @GenerateReport decorator on the tearDownClass method.
@GenerateReport
@classmethod
def tearDownClass(cls):
pass
Setup Report: Configure report settings before executing the tests using the @SetupReport decorator. This decorator is optional and can be used to change the final destination of the report or include an image.
@SetupReport(report_destination_path="results/", image_path="image.png")
@classmethod
def setUpClass(cls):
pass
Get Screenshot: Specify the function responsible for capturing a screenshot during the execution of a step using the @GetScreenshot decorator.
@GetScreenshot
def get_screenshot(self):
return self.driver.get_screenshot_as_png()
The @GenerateReport decorator generates a detailed test report on html, including the results of each step and test case. This report can be customized and saved to a specified directory.
If you would like to contribute to the development of this library, please submit a pull request or open an issue on GitHub.
This project is licensed under the MIT License.
For any questions or suggestions, please contact
FAQs
This is a library for generating a report for your automated tests.
We found that test-report-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.