Skip to content

Commit

Permalink
Fix code coverage (#167)
Browse files Browse the repository at this point in the history
* Test coverage fix

* Test coverage fix

* Test coverage fix

* Test coverage fix

* Test coverage fix

* Test coverage fix

* Test coverage fix

* Test coverage fix

* Test coverage fix

* Fix multiple cucumber scenarios. Persistent webdriver session

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Test run integration tests

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Add caching back

* Fix some tests

* Fix some tests

* Fix some tests

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.

* Test new fixes for coverage.
  • Loading branch information
Pelayori authored Apr 5, 2024
1 parent 62477aa commit e7e1c19
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 196 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/unit-tests-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,31 @@ jobs:

- name: Start the application
run: |
./mvnw spring-boot:run &
sleep 15
./mvnw spring-boot:run > logs.txt 2>&1 &
echo $! > spring-boot-app.pid
sleep 5
env:
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/test_database
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.cj.jdbc.Driver
SPRING_PROFILES_ACTIVE: test
- name: Check listening ports
run: ss -tuln
- name: Run all tests with sonar analysis
- name: Run tests
run: |
./mvnw -B org.jacoco:jacoco-maven-plugin:prepare-agent clean test sonar:sonar -DEXCLUDE_JUNIT=true -Dsonar.projectKey=Arquisoft_wiq_es04b -Dsonar.organization=arquisoft -Dsonar.branch.name=${{ github.ref }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dspring.profiles.active=test -Dspring.datasource.url=jdbc:mysql://localhost:3306/test_database -Dspring.datasource.username=root -Dspring.datasource.password=root -Dspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -Dtest="com.uniovi.Wiq_UnitTests,com.uniovi.CucumberRunnerTests"
./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify -Dspring.datasource.url=jdbc:mysql://localhost:3306/test_database -Dspring.datasource.username=root -Dspring.datasource.password=root -Dspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
env:
SPRING_PROFILES_ACTIVE: test
headless: true
headless: true
EXCLUDE_JUNIT: true
- name: Show app logs
if: always()
run: |
cat logs.txt
- name: Shut down the application
run: |
kill $(cat spring-boot-app.pid)
- name: Collect Jacoco report and send to Sonar
run: |
./mvnw org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=Arquisoft_wiq_es04b -Dsonar.organization=arquisoft -Dsonar.branch.name=${{ github.ref }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dspring.profiles.active=test
150 changes: 0 additions & 150 deletions database/hsqldb/index.html

This file was deleted.

10 changes: 0 additions & 10 deletions database/hsqldb/readme.txt

This file was deleted.

59 changes: 28 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<java.version>17</java.version>
<sonar.sources>src/main/java,src/test/resources/features</sonar.sources>
<sonar.jacoco.reportPaths>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPaths>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -117,7 +116,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version> <!-- Use the latest version available -->
<version>0.8.11</version>
<executions>
<execution>
<goals>
Expand All @@ -126,27 +125,14 @@
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<phase>report</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-merge</id>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/jacoco-merged.exec</destFile>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
Expand All @@ -155,26 +141,37 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<excludes>
<exclude>**/CucumberRunnerTests.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/Wiq_UnitTests.java</include>
<include>**/CucumberRunnerTests.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<jvmArguments>
-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/0.8.11/org.jacoco.agent-0.8.11-runtime.jar=output=tcpserver,address=*,port=6300,includes=*
</jvmArguments>
</configuration>
</execution>
<!-- Define stop goal execution as well -->
</executions>
<configuration>
<jvmArguments>
-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/0.8.11/org.jacoco.agent-0.8.11-runtime.jar=destfile=${project.build.directory}/jacoco.exec,includes=*,output=file
</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
Expand Down Expand Up @@ -222,4 +219,4 @@
</dependencies>
</profile>
</profiles>
</project>
</project>
1 change: 1 addition & 0 deletions src/test/java/com/uniovi/CucumberRunnerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.jupiter.api.Tag;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;

Expand Down
6 changes: 6 additions & 0 deletions src/test/java/com/uniovi/steps/NavigateHomeStep.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.uniovi.steps;

import com.uniovi.*;
import com.uniovi.dto.RoleDto;
import com.uniovi.services.RoleService;
import com.uniovi.util.SeleniumUtils;
import io.cucumber.java.After;
import io.cucumber.java.AfterAll;
Expand All @@ -12,11 +14,15 @@
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class NavigateHomeStep extends Wiq_IntegrationTests {

@Autowired
private RoleService roleService;

@Given("I am in the home page")
public void i_am_in_the_home_page() {
driver.navigate().to(URL);
Expand Down

0 comments on commit e7e1c19

Please sign in to comment.