Test task is failing. As its unable to find the resource file required (I am trying to load the resource file using ClasspathStoryFinder.class.getClassLoader().getResources("") under target folder. Target is not generated until build is success.
Note: When i ran test testcase using junit it works properly as it can able to find the resource file from the class path.
So is the resource you are trying to load in your test generated (or copied) by some other Gradle build step? If so, then you’ll probably have to have the ‘test’ task depend on that step to ensure the resources exist before Gradle attempts to execute your tests.
Sorry to bug you again. I am new to gradle setup. Target will not be generated until build is successful. But build is failing because of :test task is failing.
Below is overview of my scenario.
I want to test jbehave testcase. Which require *.story file under src/test/resources test classes are available @ src/test
I’m not sure what you mean when you say that “target” won’t be built unless the build is successful. The ‘test’ task should depend on ‘compileTestJava’ which is responsible for copying all of your classpath resources, including those in src/test/resources.
Assuming a file that exists src/test/resources/foo.story, you should be able to access that resource from a test class via the syntax in your original post, for example:
Target means, target folder which will be generated by gradle build.
debug statement from gradle build…
Searching for stories called teststory in [C:\opt\OpsIT-berlin-clock-b773c806fcc9\target\classes\test, C:\opt\OpsIT-berlin-clock-b773c806fcc9\target\resources\test, C:\opt\OpsIT-berlin-clock-b773c806fcc9\target\classes\main]
but by the time it’s checking, resources under target is not available.