Skip to content

Commit

Permalink
Test no headless
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelayori committed Mar 19, 2024
1 parent 3e066d3 commit ce54744
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/unit-tests-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ jobs:
run: |
./mvnw -B verify 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 -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
SPRING_PROFILES_ACTIVE: test
headless: true
15 changes: 12 additions & 3 deletions src/test/java/com/uniovi/Wiq_IntegrationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;

Expand All @@ -20,12 +22,19 @@ class Wiq_IntegrationTests {

static WebDriver driver;

@Autowired
Environment env;

@BeforeEach
public void begin() {
WebDriverManager.firefoxdriver().setup();
FirefoxOptions options = new FirefoxOptions();
//options.addArguments("--headless");
driver = new FirefoxDriver(options);
if (env.getProperty("headless") != null && env.getProperty("headless").equals("true")) {
FirefoxOptions options = new FirefoxOptions();
options.addArguments("--headless");
driver = new FirefoxDriver(options);
} else {
driver = new FirefoxDriver();
}
driver.navigate().to(URL);
}

Expand Down

0 comments on commit ce54744

Please sign in to comment.