From e7e1c1965b4da4f23fab7b83897c098c70c5de05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pelayo=20Rojas=20=C3=8D=C3=B1igo?= <31128562+Pelayori@users.noreply.github.com> Date: Fri, 5 Apr 2024 02:27:44 +0200 Subject: [PATCH] Fix code coverage (#167) * 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. --- .github/workflows/unit-tests-push.yml | 23 ++- database/hsqldb/index.html | 150 ------------------ database/hsqldb/readme.txt | 10 -- pom.xml | 59 ++++--- .../java/com/uniovi/CucumberRunnerTests.java | 1 + .../com/uniovi/steps/NavigateHomeStep.java | 6 + 6 files changed, 53 insertions(+), 196 deletions(-) delete mode 100644 database/hsqldb/index.html delete mode 100644 database/hsqldb/readme.txt diff --git a/.github/workflows/unit-tests-push.yml b/.github/workflows/unit-tests-push.yml index a05c42bd..17e4cfb8 100644 --- a/.github/workflows/unit-tests-push.yml +++ b/.github/workflows/unit-tests-push.yml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/database/hsqldb/index.html b/database/hsqldb/index.html deleted file mode 100644 index a8fe5467..00000000 --- a/database/hsqldb/index.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - HSQLDB - - - HyperSQL logo -


-

-

HyperSQL version 2.7.2 Distribution
-

-

HSQLDB (HyperSQL Database) is a relational - database management system written in Java. Now in its 23rd year, - HSQLDB version 2.7.2 is the result of 12 years - improvements since version 2.0. It offers many features and - adheres closely to the latest SQL and JDBC 4.2 standards.

-

This release should be used in preference to earlier 2.x - releases, as it fixes a number of bugs and regressions, as well as - improving functionality and adding new features.

-

The main jars in this package are Java module jars and compatible - with Java 11 and later. The alternative jars are compatible with - Java 8 and later. The jars have been tested with JRE 8, 11 and 17. - A separate jar from the web site has the same functionality as - version 2.7.2 minus the java.time features and can be used with Java 6 and 7. -

-

SUPPORTWARE

-

The development and maintenance of  HyperSQL has been - possible - because of financial contributions by business users. We need - renewed - contributions. Please subscribe to SupportWare at  http://hsqldb.org/web/supportware - . Especially if you include HSQLDB as part of an applications that - you sell, - or use it in production, you are expected to subscribe to - SupportWare at the appropriate level. Subscribers get priority for - support and feature requests.

-

COMMERCIAL SUPPORT

-

Hourly paid support for HyperSQL is available - from http://hyperxtreme.co.uk. - This service provides all the help needed to use or integrate - HSQLDB with your application.

-

SCALABILITY UPGRADES

-

For applications that require more speed with very large data - sets, or need to store more data in a memory database, the - commercial product, HyperXtremeSQL is available - from http://hyperxtreme.co.uk. - This product is fully compatible with HSQLDB SQL queries and JDBC - calls. It also has - extensive SQL OLAP and procedural language features, together with - extra crash-recovery and database management capabilities.

-

PACKAGE CONTENTS

-

This download contains the following files and directories:

-

bin

-

This directory contains some Windows utility wrapper scripts.

-

build

-

This directory contains the ant - build.xml script and Gradle build files. See the Building HyperSQL Jars - appendix of the HyperSQL User Guide for details.

-

classes

-

When the jar is rebuilt, this - directory contains the *.class files generated by the ANT build - tool. - It does not exist in the distribution zip.

-

doc

-

A set of HTML, PDF and text - documents covering different aspects of HSQLDB and some of its - utilities.

-

HyperSQL - User Guide in HTML format.
- HyperSQL User Guide - in PDF format.

-

HyperSQL - Utilities Guide in HTML format.
- HyperSQL - Utilities Guide in PDF - format.

-

The JavaDoc - for public classes, including the JDBC documentation.

-

Chronological list of - minor changes and bug fixes since the release of version 2.0 changelist_2_0.txt -

-

HyperSQL source and binaries are released under the 3-clause BSD - license. The license text hsqldb_lic.txt - is for sources developed entirely by the HSQL Development Group. - The hypersonic_lic.txt - is for the few sources that contain code from the closed - HypersonicSQL project.

-

lib

-

The jar needed for running HyperSQL - and its GUI utilities (hsqldb.jar) has been pre-built in this - directory. The jar for SqlTool (sqltool.jar) is - also in this directory. The jars are - compatible with Java version 8 and above. The extra zip file in - the directory is needed - only for - recompiling hsqldb and is not required for deployment.

-

src

-

All source code is in this directory.

-

testrun

-

Contains test scripts for the - database engine and SqlTool. These scripts are run by separate - test - utilities for the engine and SqlTool

-

doc-src

-

All source code for documentation is in this directory.

-

CHANGES

- -

UPDATES

-

We constantly fix reported issues. Please check the web site - regularly - for latest updated version and latest information. Follow us - on Twitter @hypersql for updates.

-

RESOURCES

-

Support documentation for HyperSQL including the FAQ and links to - resources are available - from http://hsqldb.org/support - in various forms, including user forums. Support is given to open - source developers for using HSQLDB in their products.

-

NOTE

- The highly configurable java source code formatter Jindent is used to format the HSQLDB - source code. -

This Software is developed and published by the HSQL Development - Group

-

Fred Toussi (fredt (at) - users.sourceforge.net)
- Blaine Simpson (blaine dot simpson (at) admc dot com)

-

http://hsqldb.org 

- - diff --git a/database/hsqldb/readme.txt b/database/hsqldb/readme.txt deleted file mode 100644 index 1e481f28..00000000 --- a/database/hsqldb/readme.txt +++ /dev/null @@ -1,10 +0,0 @@ -Readme File - -This package contains HyperSQL version 2.7.2 - -HyperSQL Database is a relational database management system and a set of tools -written in Java. -HyperSQL is also known as HSQLDB. - -The file "index.html" explains the contents of this distribution and has -links to documentation and support resources. diff --git a/pom.xml b/pom.xml index 54cdb311..83732151 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,6 @@ 17 src/main/java,src/test/resources/features ${project.basedir}/target/jacoco.exec - ${project.basedir}/target/site/jacoco/jacoco.xml @@ -117,7 +116,7 @@ org.jacoco jacoco-maven-plugin - 0.8.11 + 0.8.11 @@ -126,27 +125,14 @@ report - test + report report - - - jacoco-merge - verify - - merge - - - - ${project.build.directory} - - *.exec - - - - ${project.build.directory}/jacoco-merged.exec + + XML + @@ -155,9 +141,25 @@ org.apache.maven.plugins maven-surefire-plugin 3.2.5 + + + **/CucumberRunnerTests.java + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M5 + + + + verify + + + - **/Wiq_UnitTests.java **/CucumberRunnerTests.java @@ -165,16 +167,11 @@ org.springframework.boot spring-boot-maven-plugin - - - - - -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=* - - - - - + + + -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 + + @@ -222,4 +219,4 @@ - + \ No newline at end of file diff --git a/src/test/java/com/uniovi/CucumberRunnerTests.java b/src/test/java/com/uniovi/CucumberRunnerTests.java index 328e229d..8dba5031 100644 --- a/src/test/java/com/uniovi/CucumberRunnerTests.java +++ b/src/test/java/com/uniovi/CucumberRunnerTests.java @@ -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; diff --git a/src/test/java/com/uniovi/steps/NavigateHomeStep.java b/src/test/java/com/uniovi/steps/NavigateHomeStep.java index f0652924..0c24a151 100644 --- a/src/test/java/com/uniovi/steps/NavigateHomeStep.java +++ b/src/test/java/com/uniovi/steps/NavigateHomeStep.java @@ -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; @@ -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);