Skip to content

Commit d01f080

Browse files
committed
chore: fix integration tests
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 39b5e77 commit d01f080

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

.github/workflows/sonar.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
PR_NUMBER=$(<prInfo/PR)
4242
BASE_REF=$(<prInfo/base_ref)
4343
HEAD_REF=$(<prInfo/head_ref)
44-
./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}}
44+
./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}}
4545
else
46-
./gradlew sonar
46+
./gradlew build sonar
4747
fi
4848
shell: bash
4949

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ tasks {
4646
property("sonar.organization", "redhat-developer")
4747
property("sonar.host.url", "https://sonarcloud.io")
4848
property("sonar.junit.reportsPath", layout.buildDirectory.dir("test-results").get().asFile.absolutePath)
49-
property("sonar.gradle.skipCompile", "true")
5049
}
5150
}
5251
}

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/screenshot/ScreenshotUtils.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.File;
1919
import java.io.IOException;
2020
import java.nio.file.Files;
21+
import java.nio.file.Path;
2122
import java.nio.file.Paths;
2223
import java.time.LocalDateTime;
2324
import java.time.format.DateTimeFormatter;
@@ -48,12 +49,13 @@ private ScreenshotUtils() {
4849
public static File takeScreenshot(RemoteRobot remoteRobot, String comment) {
4950
try {
5051
BufferedImage screenshotBufferedImage = remoteRobot.getScreenshot();
51-
boolean doesScreenshotDirExists = Files.exists(Paths.get(SCREENSHOT_LOCATION));
52+
Path path = Paths.get(SCREENSHOT_LOCATION);
53+
boolean doesScreenshotDirExists = Files.exists(path);
5254
if (!doesScreenshotDirExists) {
53-
Files.createDirectory(Paths.get(SCREENSHOT_LOCATION));
55+
Files.createDirectory(path);
5456
}
55-
String screenshotFilename = getTimeNow("yyyy_MM_dd_HH_mm_ss");
56-
String screenshotComment = comment == null || comment.equals("") ? "" : "_" + comment;
57+
String screenshotFilename = getTimeNow();
58+
String screenshotComment = comment == null || comment.isEmpty() ? "" : "_" + comment;
5759
String screenshotPathname = SCREENSHOT_LOCATION + screenshotFilename + screenshotComment + "." + FILETYPE;
5860
File screenshotFile = new File(screenshotPathname);
5961
ImageIO.write(screenshotBufferedImage, FILETYPE, screenshotFile);
@@ -74,8 +76,8 @@ public static File takeScreenshot(RemoteRobot remoteRobot) {
7476
return takeScreenshot(remoteRobot, "");
7577
}
7678

77-
private static String getTimeNow(String timeFormat) {
78-
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(timeFormat);
79+
private static String getTimeNow() {
80+
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss");
7981
LocalDateTime localTimeNow = LocalDateTime.now();
8082
return dateTimeFormatter.format(localTimeNow);
8183
}

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.nio.file.Files;
2323
import java.time.Duration;
2424

25-
import static org.junit.jupiter.api.Assertions.assertTrue;
25+
import static org.junit.jupiter.api.Assertions.assertEquals;
2626
import static org.junit.jupiter.api.Assertions.fail;
2727

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

0 commit comments

Comments
 (0)