diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1d07550 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +name: Java CI with Maven + +on: + pull_request: + branches: + - master # 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 diff --git a/pom.xml b/pom.xml index 8171c1a..96835fe 100644 --- a/pom.xml +++ b/pom.xml @@ -18,57 +18,77 @@ + - junit - junit - 4.13 + org.junit.jupiter + junit-jupiter-api + 5.10.0 test + + org.junit.jupiter + junit-jupiter-engine + 5.10.0 + test + + + org.junit.platform + junit-platform-suite + 1.10.0 + test + + + + org.projectlombok + lombok + 1.18.36 + provided + + + + org.assertj + assertj-core + 3.27.3 + test + + - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.2 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + **/*Test.java + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + + **/*Test.java + + + true + true + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 3.1.2 + + + + diff --git a/src/main/java/Employee.java b/src/main/java/Employee.java new file mode 100644 index 0000000..b54b96e --- /dev/null +++ b/src/main/java/Employee.java @@ -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; +} diff --git a/src/test/java/EmployeeTest.java b/src/test/java/EmployeeTest.java new file mode 100644 index 0000000..6bad4e9 --- /dev/null +++ b/src/test/java/EmployeeTest.java @@ -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"); + } +} \ No newline at end of file