Table of Contents
Spectrum is an e2e test automation framework that leverages JUnit 6 and Selenium 4 to provide these features automatically:
- Driver management with auto-waiting, to highly reduce flakiness
- Generation of a html report with the execution video, coverage and several additional reports. All fully customisable
- Mail/Slack notifications with reports as attachments
- It is fully configurable via a declarative yaml file, providing out-of-the-box defaults to let you run tests with no additional configuration
- It supports browsers automation via Selenium and mobile and desktop automation via Appium
- It supports WebDriver BiDi protocol
Spectrum manages all the boilerplate code, allowing you to focus on test logic: you just need to write a JUnit test using the native Selenium API as you would do in a vanilla Selenium test, and Spectrum will enrich your suite transparently. Be sure to check the full documentation to see all the available features.
⚠️ Spectrum requires Java 21 or newer.
The easiest way is to take the three steps listed below, as shown in this video:
Spectrum.project.creation.mp4
-
Generate a new project leveraging the Spectrum Archetype:
mvn archetype:generate -DarchetypeGroupId=io.github.giulong -DarchetypeArtifactId=spectrum-archetype
-
Run the
LoginFormIT
demo test. -
Check the generated report, which opens automatically in your browser.
⚠️ Tests run on Chrome by default. As shown in the video above, you can change this with:
-Dspectrum.driver=firefox
,-Dspectrum.driver=edge
or-Dspectrum.driver=safari
Here's an overview of the project created by the archetype, along with the generated report and video:
video-readme.mp4
You can also configure Spectrum to produce additional reports, such as summary and coverage:
If you like Spectrum, please consider giving it a GitHub Star ⭐
To start without the archetype, it's as simple as following these steps:
-
Add the Spectrum dependency to your project, you can find the snippet for every build tool here.
<dependency> <groupId>io.github.giulong</groupId> <artifactId>spectrum</artifactId> <version>1.26.1</version> <scope>test</scope> </dependency>
-
Create the
HelloWorldIT
test class extendingSpectrumTest
:import io.github.giulong.spectrum.SpectrumTest; import org.junit.jupiter.api.Test; public class HelloWorldIT extends SpectrumTest<Void> { @Test public void dummyTest() { driver.get(configuration.getApplication().getBaseUrl()); } }
-
create a basic
src/test/resources/configuration.yaml
:application: baseUrl: https://the-internet.herokuapp.com/ # Change this with your app's landing page video: # video of the execution attached to the html report (will be empty since the test is doing nothing) frames: - autoBefore extent: openAtEnd: true # the html report will open automatically in your browser after the execution
-
Run the test!
Contributions to Spectrum are welcome! Please check out the CONTRIBUTING.md and the open issues.