Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions java-cucumber-maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This simple demo shows how Testomat.io Java reporter works in your project.
│ │ ├── ProductSteps
│ │ ├── ReportSteps
│ │ └── UserSteps
│ └── RunnerTest
│ └── TestRunner
└── resources/
└── features/
├── notification.feature
Expand All @@ -43,13 +43,9 @@ This simple demo shows how Testomat.io Java reporter works in your project.
cd java-cucumber-maven
```

2. Install dependencies
2. Install dependencies (run this commands in Bash)
```sh
mvn install:install-file\
-Dfile=lib/java-reporter-0.1.0.jar\
-Dversion=0.1.0 -Dpackaging=jar\
-Dgroup=com.testomatio.reporter\
-DartifactId=java-reporter
mvn install:install-file -Dfile=lib/java-reporter-0.1.0.jar -Dversion=0.1.0 -Dpackaging=jar -Dgroup=com.testomatio.reporter -DartifactId=java-reporter
```
```sh
mvn clean
Expand Down
7 changes: 6 additions & 1 deletion java-cucumber-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.opentest4j</groupId>
<artifactId>opentest4j</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
Expand Down Expand Up @@ -52,7 +57,7 @@
<version>3.0.0-M7</version>
<configuration>
<includes>
<include>**/RunnerTest.java</include>
<include>**/TestRunner.java</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ testomatio.batch.size=5
testomatio.batch.flush.interval=20
testomatio.url=https://app.testomat.io/
testomatio.run.title=
testomatio.api.key=${TESTOMATIO_API_KEY}
testomatio.api.key=

## (OFF, SEVERE, WARNING, INFO, FINE, FINER, FINEST, ALL)
testomatio.log.level=INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/features",
glue = "steps",
glue = {"steps"},
plugin = {
"pretty",
"json:target/cucumber-reports/cucumber.json",
"html:target/cucumber-reports/report",
"com.testomatio.reporter.core.framework_integration.CucumberListener"
},
tags = "not @ignore"
}
)
public class RunnerTest {
public class TestRunner {
}
2 changes: 2 additions & 0 deletions java-junit-maven-0.1.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/logs/
**/target/
109 changes: 109 additions & 0 deletions java-junit-maven-0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Java reporter integration with JUnit5

## Overview

This simple demo shows how Testomat.io Java reporter works in your project.

- Includes a pack of 90 tests. Some will fail on purpose and other will be disabled for demo.

## Structure

```
src/
├── main/
│ ├── java/
│ │ └── com/library/
│ │ ├── util/
│ │ │ └── BookUtils.java
│ │ ├── Author.java
│ │ ├── Book.java
│ │ ├── Genre.java
│ │ ├── Library.java
│ │ ├── LibraryCard.java
│ │ ├── Loan.java
│ │ ├── Publisher.java
│ │ └── Reader.java
│ └── resources/
│ └── junit-platform.properties
└── test/
└── java/
└── library/
├── AuthorTest.java
├── BookTest.java
├── LibraryTest.java
├── LoanTest.java
└── ReaderTest.java
```

## Installation

1. Clone the repository

```sh
git clone <repo-url>
cd java-junit-maven-0.1.0
```

2. Install dependencies

```sh
mvn install:install-file\
-Dfile=lib/java-reporter-0.1.0.jar\
-Dversion=0.1.0 -Dpackaging=jar\
-Dgroup=com.testomatio.reporter\
-DartifactId=java-reporter
```

```sh
mvn clean
```

```sh
mvn install -DskipTests
```

## Configurations

**By default, the library runs with properties default values except `testomatio.api.key`**

You can pass your custom properties as JVM properties, OS env variables or in the `testomatio.properties` file.

The file, if you want to use this approach, must be created int the `main/resources` folder.

To let JUnit run extension automatically - you will need to add this line into your **junit-platform.properties** file:

```properties
junit.jupiter.extensions.autodetection.enabled=true
```

- Optionally, in the `testomatio.properties` file can configure run parameters:

```properties
testomatio.batch.size=5
testomatio.url=https://app.testomat.io/
testomatio.run.title=
testomatio.api.key=
## (OFF, SEVERE, WARNING, INFO, FINE, FINER, FINEST, ALL)
testomatio.log.level=INFO
testomatio.log.file=logs/testomatio.log
testomatio.log.console=true
```

And the default is "Default run title", so you might want to change it.

## Run

Run tests with

```sh
mvn test -D=tstmt_key
```

where `tstmt_key` is your Testomat.io key from a particular project.

As a result, you will see a run report in your Project tab -> Runs on Testomat.io.

<div align="center">
<img src="img/runReport.png" alt="demo report result png" style="max-width: 70%; max-height: 420px;">
</div>

Binary file added java-junit-maven-0.1.0/img/runReport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
34 changes: 34 additions & 0 deletions java-junit-maven-0.1.0/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.testomatio.reporter</groupId>
<artifactId>java-junit-maven-0.1.0</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.9.2</junit.version>

</properties>

<dependencies>
<dependency>
<groupId>com.testomatio.reporter</groupId>
<artifactId>java-reporter</artifactId>
<version>0.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
112 changes: 112 additions & 0 deletions java-junit-maven-0.1.0/src/main/java/com/library/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.library;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Author {
private String id;
private String firstName;
private String lastName;
private LocalDate birthDate;
private String nationality;
private List<Book> books;

public Author(String id, String firstName, String lastName, LocalDate birthDate, String nationality) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.birthDate = birthDate;
this.nationality = nationality;
this.books = new ArrayList<>();
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getFullName() {
return firstName + " " + lastName;
}

public LocalDate getBirthDate() {
return birthDate;
}

public void setBirthDate(LocalDate birthDate) {
this.birthDate = birthDate;
}

public String getNationality() {
return nationality;
}

public void setNationality(String nationality) {
this.nationality = nationality;
}

public List<Book> getBooks() {
return new ArrayList<>(books);
}

public void addBook(Book book) {
if (!books.contains(book)) {
books.add(book);
}
}

public void removeBook(Book book) {
books.remove(book);
}

public int getBookCount() {
return books.size();
}

public int getAge() {
return LocalDate.now().getYear() - birthDate.getYear();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Author author = (Author) o;
return Objects.equals(id, author.id);
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public String toString() {
return "Author{" +
"id='" + id + '\'' +
", fullName='" + getFullName() + '\'' +
", nationality='" + nationality + '\'' +
'}';
}
}
Loading
Loading