Skip to content

Workflow #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Java CI with Maven

on:
pull_request:
branches:
- main # Déclenche l'action sur une PR vers la branche `main`

jobs:
build:
runs-on: ubuntu-latest # Utilisation de la dernière version d'Ubuntu pour exécuter l'action

steps:
- name: Checkout repository
uses: actions/checkout@v2 # Clone ton code dans l'environnement d'exécution

- name: Set up JDK 11
uses: actions/setup-java@v2 # Installe JDK 11
with:
java-version: '11'
distribution: 'adoptopenjdk'

- name: Build with Maven
run: mvn clean install # Compile ton projet Maven

- name: Run tests
run: mvn test # Lance les tests unitaires
112 changes: 66 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,77 @@
</properties>

<dependencies>
<!-- JUnit 5 dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version> <!-- Remplacez par la dernière version stable -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.0</version> <!-- Remplacez par la dernière version stable -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.10.0</version> <!-- Remplacez par la dernière version stable -->
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.27.3</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version> <!-- Remplacez par la dernière version stable -->
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<!-- Plugin Surefire pour exécuter les tests et générer les rapports -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version> <!-- Utilisez la dernière version stable -->
<configuration>
<!-- Inclure tous les fichiers de test -->
<includes>
<include>**/*Test.java</include>
</includes>
<!-- Générer des rapports détaillés -->
<printSummary>true</printSummary>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
<!-- Plugin pour générer un rapport HTML des tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.1.2</version> <!-- Utilisez la dernière version stable -->
</plugin>
</plugins>

</build>

</project>
13 changes: 13 additions & 0 deletions src/main/java/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class Employee {

private String name;
private String sexe;
private String adress;
private int salary;
private int idEmployee;
}
27 changes: 27 additions & 0 deletions src/test/java/EmployeeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class EmployeeTest {

Employee testEmployee = new Employee("Steeve", "Male", "Canada", 5200, 123);

@BeforeAll
public static void debutDesTests () {
System.out.println("D.but des tests");
}

@Test
void testClassEmployee (){

Assertions.assertEquals("Steeve", testEmployee.getName(), "Le nom est bien Steeve");
}

@AfterAll
public static void finDesTests (){
System.out.println("Fin de l'exécution des tests");
}
}