Skip to content

Commit

Permalink
chore: fix integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet committed Feb 4, 2025
1 parent 39b5e77 commit d01f080
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
PR_NUMBER=$(<prInfo/PR)
BASE_REF=$(<prInfo/base_ref)
HEAD_REF=$(<prInfo/head_ref)
./gradlew sonar -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
./gradlew build sonar -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
else
./gradlew sonar
./gradlew build sonar
fi
shell: bash

1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ tasks {
property("sonar.organization", "redhat-developer")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.junit.reportsPath", layout.buildDirectory.dir("test-results").get().asFile.absolutePath)
property("sonar.gradle.skipCompile", "true")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -48,12 +49,13 @@ private ScreenshotUtils() {
public static File takeScreenshot(RemoteRobot remoteRobot, String comment) {
try {
BufferedImage screenshotBufferedImage = remoteRobot.getScreenshot();
boolean doesScreenshotDirExists = Files.exists(Paths.get(SCREENSHOT_LOCATION));
Path path = Paths.get(SCREENSHOT_LOCATION);
boolean doesScreenshotDirExists = Files.exists(path);
if (!doesScreenshotDirExists) {
Files.createDirectory(Paths.get(SCREENSHOT_LOCATION));
Files.createDirectory(path);
}
String screenshotFilename = getTimeNow("yyyy_MM_dd_HH_mm_ss");
String screenshotComment = comment == null || comment.equals("") ? "" : "_" + comment;
String screenshotFilename = getTimeNow();
String screenshotComment = comment == null || comment.isEmpty() ? "" : "_" + comment;
String screenshotPathname = SCREENSHOT_LOCATION + screenshotFilename + screenshotComment + "." + FILETYPE;
File screenshotFile = new File(screenshotPathname);
ImageIO.write(screenshotBufferedImage, FILETYPE, screenshotFile);
Expand All @@ -74,8 +76,8 @@ public static File takeScreenshot(RemoteRobot remoteRobot) {
return takeScreenshot(remoteRobot, "");
}

private static String getTimeNow(String timeFormat) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(timeFormat);
private static String getTimeNow() {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss");
LocalDateTime localTimeNow = LocalDateTime.now();
return dateTimeFormatter.format(localTimeNow);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.nio.file.Files;
import java.time.Duration;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

/**
Expand All @@ -38,7 +38,7 @@ public void takeScreenshotTest() {
int numberOfScreenshotBefore = getNumberOfSavedScreenshot();
File screenshotFile = ScreenshotUtils.takeScreenshot(remoteRobot);
int numberOfScreenshotAfter = getNumberOfSavedScreenshot();
assertTrue(numberOfScreenshotAfter == numberOfScreenshotBefore + 1, "Screenshot should be already saved but is not.");
assertEquals(numberOfScreenshotAfter, numberOfScreenshotBefore + 1, "Screenshot should be already saved but is not.");
try {
Files.delete(screenshotFile.toPath());
} catch (IOException e) {
Expand Down

0 comments on commit d01f080

Please sign in to comment.