Closed kazurayam closed 10 months ago
supported this. See the following for how to use it
@Test
public void test_resolveOutput_into_custom_location() throws Exception {
TestHelper th =
new TestHelper(this.getClass())
.setOutputDirPath(Paths.get("build/tmp/testOutput"));
Path p = th.resolveOutput("hello.txt");
Files.write(p, "Hello, world!".getBytes("utf-8"));
assertThat(p.getParent() // expecting testOutput
.getFileName().toString())
.isEqualTo("testOutput");
assertThat(p.getParent() // expecting testOutput
.getParent() // expecting tmp
.getFileName().toString())
.isEqualTo("tmp");
assertThat(p.getParent() // expecting testOutput
.getParent() // expecting tmp
.getParent() // expecting build
.getFileName().toString())
.isEqualTo("build");
}
In the kazurayam8a branch, I developed
com.kazurayam.unittest.ProjectDirectoryResolver
class.It has the following fragment:
Here I assumed 2 constant values:
Arrays.asList("build", "classes", "java", "test")
as Gradle's sub-directory pattern,Arrays.asList("target", "test-classes")
as Maven's sub-driectory pattern.The current version supports only these 2 subdirectory structure. I should introduce one more abstraction. The class should enable users to set more subdirectory patterns.