New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create output dir for code coverage report #316

Closed
rkuchynski opened this Issue Aug 2, 2016 · 9 comments

Comments

3 participants
@rkuchynski

rkuchynski commented Aug 2, 2016

Issue happens with JMockit 1.26 only

I'm running JMockit with the following JVM args

-javaagent:D:\path\to\jmockit.jar=coverage
-Djmockit-coverage-output=html
-Djmockit-coverage-outputDir=D:\my_project\build\reports\coverage
-Djmockit-coverage-srcDirs=D:\my_project\src\main\java
-Djmockit-coverage-metrics=all
-Djmockit-coverage-excludes=.+\\w+(Test)(\\$.+)?\\b

This solution successfully produce coverage reports with JMockit 1.25 and 1.26, but with 1.26 it prints the following error to console:

Exception in thread "Thread-5" java.lang.AssertionError: Failed to create output dir: D:\my_project\build\reports\coverage
        at mockit.coverage.reporting.OutputFile.getOutputFileCreatingDirIfNeeded(OutputFile.java:40)
        at mockit.coverage.reporting.OutputFile.<init>(OutputFile.java:27)
        at mockit.coverage.reporting.sourceFiles.FileCoverageReport.<init>(FileCoverageReport.java:40)
        at mockit.coverage.reporting.CoverageReport.generateFileCoverageReport(CoverageReport.java:104)
        at mockit.coverage.reporting.CoverageReport.generateFileCoverageReportsWhileBuildingPackageLists(CoverageReport.java:90)
        at mockit.coverage.reporting.CoverageReport.generate(CoverageReport.java:56)
        at mockit.coverage.OutputFileGenerator.generateHTMLReportIfRequested(OutputFileGenerator.java:168)
        at mockit.coverage.OutputFileGenerator.generate(OutputFileGenerator.java:111)
        at mockit.coverage.CodeCoverage$1.run(CodeCoverage.java:67)
JMockit: Coverage report written to D:\my_project\build\reports\coverage
@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Aug 2, 2016

Member

I am unable to reproduce the problem. Could you post a small, but complete, sample project?

Member

rliesenfeld commented Aug 2, 2016

I am unable to reproduce the problem. Could you post a small, but complete, sample project?

@siarhei-usau

This comment has been minimized.

Show comment
Hide comment
@siarhei-usau

siarhei-usau Aug 2, 2016

This happens with java 8u92 64 bit on windows 7 64bit. We will provide test case tomorrow.

siarhei-usau commented Aug 2, 2016

This happens with java 8u92 64 bit on windows 7 64bit. We will provide test case tomorrow.

@siarhei-usau

This comment has been minimized.

Show comment
Hide comment
@siarhei-usau

siarhei-usau Aug 2, 2016

I should add that regardless of this trace the report is created btw this message is very frustrating

siarhei-usau commented Aug 2, 2016

I should add that regardless of this trace the report is created btw this message is very frustrating

@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Aug 2, 2016

Member

my_project

Attached a zip file with my initial trial project (for IntelliJ IDEA). Github is complaining about not supporting a zip file, so I renamed it to a ".gif".

Member

rliesenfeld commented Aug 2, 2016

my_project

Attached a zip file with my initial trial project (for IntelliJ IDEA). Github is complaining about not supporting a zip file, so I renamed it to a ".gif".

@rkuchynski

This comment has been minimized.

Show comment
Hide comment
@rkuchynski

rkuchynski Aug 3, 2016

Sorry, I didn't provide all necessary information before.
I use JMockit with Gradle - it seems that version of Gradle does not matter (I tested with 2.9 and 2.14.1)
Here is a sample project reproducing this bug: myproject.zip.
Java version is 1.8.092, OS Windows 7 x64. It's really strange that everything is okay with JMockit 1.25.
If it can make any help, it's possible to attach debugger to test using the following command: gradlew clean test --tests "com.example.BillingServiceTest" -Dtest.debug (BillingServiceTest is a sample test class from the project above).

rkuchynski commented Aug 3, 2016

Sorry, I didn't provide all necessary information before.
I use JMockit with Gradle - it seems that version of Gradle does not matter (I tested with 2.9 and 2.14.1)
Here is a sample project reproducing this bug: myproject.zip.
Java version is 1.8.092, OS Windows 7 x64. It's really strange that everything is okay with JMockit 1.25.
If it can make any help, it's possible to attach debugger to test using the following command: gradlew clean test --tests "com.example.BillingServiceTest" -Dtest.debug (BillingServiceTest is a sample test class from the project above).

@siarhei-usau

This comment has been minimized.

Show comment
Hide comment
@siarhei-usau

siarhei-usau Aug 3, 2016

@rliesenfeld your test sample works properly on my env. BTW the sample that @rkuchynski prepared failed with trace.

siarhei-usau commented Aug 3, 2016

@rliesenfeld your test sample works properly on my env. BTW the sample that @rkuchynski prepared failed with trace.

@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Aug 3, 2016

Member

I don't know yet what exactly happens, but a solution is to remove the redundant use of the "-javaagent" JVM parameter, and the "coverage" system properties. Leave only "coverage-metrics=all" (to enable the coverage tool), and "coverage-outputDir" (as the desired directory differs from the default).

Member

rliesenfeld commented Aug 3, 2016

I don't know yet what exactly happens, but a solution is to remove the redundant use of the "-javaagent" JVM parameter, and the "coverage" system properties. Leave only "coverage-metrics=all" (to enable the coverage tool), and "coverage-outputDir" (as the desired directory differs from the default).

@rliesenfeld rliesenfeld added bug and removed could not reproduce labels Aug 3, 2016

@rliesenfeld rliesenfeld self-assigned this Aug 3, 2016

@siarhei-usau

This comment has been minimized.

Show comment
Hide comment
@siarhei-usau

siarhei-usau Aug 3, 2016

Thanks, but we use jmockit as main coverage reporting tool even for modules where no mocks and gradle configuration is united for all modules so your advice don't work as far as I understand it

siarhei-usau commented Aug 3, 2016

Thanks, but we use jmockit as main coverage reporting tool even for modules where no mocks and gradle configuration is united for all modules so your advice don't work as far as I understand it

@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Aug 21, 2016

Member

Fixed.

Member

rliesenfeld commented Aug 21, 2016

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment