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
8 changes: 2 additions & 6 deletions java-junit-maven-0.1.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ src/
cd java-junit-maven-0.1.0
```

2. Install dependencies
2. Install dependencies (run it 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
Expand Down
106 changes: 106 additions & 0 deletions java-testng-maven-0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Java reporter integration with TestNG

## Overview

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

- Includes a pack of 50 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/
│ │ └── testomatio.properties
│ └── test/
│ └── java/
│ └── com/
│ └── library/
│ ├── AuthorTest.java
│ ├── BookTest.java
│ ├── BookUtilsTest.java
│ ├── GenreTest.java
│ └── LibraryTest.java
├── pom.xml
└── README.md
```

## Installation

1. Clone the repository

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

2. Install dependencies (run it 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
```

```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.

The extension will run if you provide `testomatio.api.key` as a property in test run config or `mvn test`

- 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-testng-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.
53 changes: 53 additions & 0 deletions java-testng-maven-0.1.0/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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>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>
<testng.version>7.7.1</testng.version>
<maven.surefire.version>3.0.0-M9</maven.surefire.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.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opentest4j</groupId>
<artifactId>opentest4j</artifactId>
<version>1.3.0</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

</project>
112 changes: 112 additions & 0 deletions java-testng-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