Skip to content

Commit e579b74

Browse files
committed
Fix filePath for both Windows and Unix
1 parent 52d7bf7 commit e579b74

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessTaskImplTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.diffplug.gradle.spotless;
1717

1818
import java.io.File;
19+
import java.nio.file.Paths;
1920

2021
import org.assertj.core.api.Assertions;
2122
import org.gradle.api.file.DirectoryProperty;
@@ -31,15 +32,15 @@ public void testThrowsMessageContainsFilename() throws Exception {
3132
SpotlessTaskImpl task = Mockito.mock(SpotlessTaskImpl.class, Mockito.CALLS_REAL_METHODS);
3233
Mockito.when(task.getLogger()).thenReturn(Mockito.mock(Logger.class));
3334

34-
File projectDir = new File("unitTests/projectDir");
35+
File projectDir = Paths.get("unitTests","projectDir").toFile();
3536
DirectoryProperty projectDirProperty = Mockito.mock(DirectoryProperty.class, Mockito.RETURNS_DEEP_STUBS);
3637
Mockito.when(projectDirProperty.get().getAsFile()).thenReturn(projectDir);
3738

3839
Mockito.when(task.getProjectDir()).thenReturn(projectDirProperty);
3940

40-
File input = new File("unitTests/projectDir/someInput");
41+
File input = Paths.get("unitTests","projectDir", "someInput").toFile();
4142
Formatter formatter = Mockito.mock(Formatter.class);
4243

43-
Assertions.assertThatThrownBy(() -> task.processInputFile(null, formatter, input)).hasMessageContaining("unitTests/projectDir/someInput");
44+
Assertions.assertThatThrownBy(() -> task.processInputFile(null, formatter, input)).hasMessageContaining(input.toString());
4445
}
4546
}

0 commit comments

Comments
 (0)