How to use restoreOriginalClasses method of samples.powermockito.junit4.jacoco.JacocoCoverageTest class

Best Powermock code snippet using samples.powermockito.junit4.jacoco.JacocoCoverageTest.restoreOriginalClasses

Source:JacocoCoverageTest.java Github

copy

Full Screen

...39 instrumentClasses(runtime);40 runtime.startup(data);41 JUnitCore.runClasses(TargetTest.class);42 runtime.shutdown();43 restoreOriginalClasses();44 }45 private void assertCodeCoverage(CoverageBuilder coverageBuilder) {46 for (IClassCoverage classCoverage : coverageBuilder.getClasses()) {47 for (IMethodCoverage methodCoverage : classCoverage.getMethods()) {48 if (methodCoverage.getName().equals("calculateSomething")) {49 assertThat(methodCoverage.getLineCounter().getCoveredRatio()).isEqualTo(1.0);50 assertThat(methodCoverage.getLineCounter().getCoveredCount()).isEqualTo(4);51 }52 }53 }54 }55 private CoverageBuilder collectCoverage(ExecutionDataStore executionData) throws IOException {56 final CoverageBuilder coverageBuilder = new CoverageBuilder();57 final Analyzer analyzer = new Analyzer(executionData, coverageBuilder);58 for (String className : TARGET) {59 analyzer.analyzeClass(getClass().getResourceAsStream(classNameToFileName(className)), className);60 }61 return coverageBuilder;62 }63 private ExecutionDataStore getExecutionDataStore(RuntimeData data) {64 final ExecutionDataStore executionData = new ExecutionDataStore();65 final SessionInfoStore sessionInfos = new SessionInfoStore();66 data.collect(executionData, sessionInfos, false);67 return executionData;68 }69 private void restoreOriginalClasses() throws URISyntaxException, IOException {70 for (String className : TARGET) {71 final String classResource = classNameToFileName(className);72 URL classResourceURL = getClass().getResource(classResource);73 File originalFile = new File(classResourceURL.toURI());74 restoreOriginalFile(originalFile);75 }76 }77 private void instrumentClasses(IRuntime runtime) throws URISyntaxException, IOException {78 Instrumenter instr = new Instrumenter(runtime);79 for (String className : TARGET) {80 instrumentClass(instr, className);81 }82 }83 private static void copyFileUsingStream(File source, File dest) throws IOException {...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful