You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing the similiar issue in #4 but it is a single project (not a multi-project) and I am in a different path. The test resouces are subject to be called using WithMockedApplication.class.getResource(".... file name ...");
When running through SBT terminal it is failing to find the resources because it is in the path: target/scala-2.12/jacoco/instrumented-classes
while it is expected to be in the usual test-classes path which contains class files and the test resources as well: target/scala-2.12/test-classes
Actual workaround is to detect if test is running in SBT and then using a hardcoded path to obtain the resources from the test-classes folder. I would like to get rid off this hardcoded logic.
Any idea how to resolve it and how to tell SBT to use the correct path instead of the JaCoCo path?
Thank you, Christoph
Steps to Reproduce
> sbt clean test
Environment
Play Framework: 2.7
SBT version: 1.2.7
Plugin version: 3.1.0
Scala version(s): 2.11.12", "2.12.7
Java version: 8
The text was updated successfully, but these errors were encountered:
In case someone is interested how I resolved it. I am fetching the correct path using this method from an utility class called TestResources .
@Nonnull
public static Path asPath(final @Nonnull String path) {
Preconditions.checkNotNull(path);
try {
final String currentPath = TestResources.class.getResource("/").toURI().toString();
final String correctPath;
if (currentPath.contains("/jacoco/")) {
// dirty workaround for SBT because it is in wrong path
correctPath = StringUtils.substringBefore(currentPath, "/jacoco/") + "/test-classes/";
log.debug("Path changed from '{}' to '{}'", currentPath, correctPath);
} else {
// for the rest it is same
correctPath = currentPath;
}
log.debug("Look up for test resource '{}' in path: {}", path, correctPath);
return Paths.get(new URI(correctPath + path));
} catch (final URISyntaxException e) {
throw new AssertionError(String.format("Could not get resource for path: %s", path), e);
}
}
Have not found a cleaner solution yet, but the method above seems be reliable more than 1 year.
Expected vs Actual Behaviour
Hello.
I am facing the similiar issue in #4 but it is a single project (not a multi-project) and I am in a different path. The test resouces are subject to be called using
WithMockedApplication.class.getResource(".... file name ...");
When running through SBT terminal it is failing to find the resources because it is in the path:
target/scala-2.12/jacoco/instrumented-classes
while it is expected to be in the usual test-classes path which contains class files and the test resources as well:
target/scala-2.12/test-classes
Actual workaround is to detect if test is running in SBT and then using a hardcoded path to obtain the resources from the test-classes folder. I would like to get rid off this hardcoded logic.
Any idea how to resolve it and how to tell SBT to use the correct path instead of the JaCoCo path?
Thank you, Christoph
Steps to Reproduce
Environment
The text was updated successfully, but these errors were encountered: