public MutationSource(final MutationConfig mutationConfig, final TestPrioritiser testPrioritiser, final ClassByteArraySource source, final MutationInterceptor interceptor) { this.mutationConfig = mutationConfig; this.testPrioritiser = testPrioritiser; this.source = new CachingByteArraySource(source, 200); this.interceptor = interceptor; }
@Test public void shouldReturnBytesFromChild() { final Optional<byte[]> childResult = Optional.ofNullable(new byte[0]); when(this.source.getBytes("someClass")).thenReturn(childResult); final CachingByteArraySource testee = new CachingByteArraySource(this.source, 2); assertThat(testee.getBytes("someClass")).isSameAs(childResult); }
@Test public void shouldCacheByteFromChild() { when(this.source.getBytes("someClass")).thenReturn(Optional.ofNullable(new byte[0])); final CachingByteArraySource testee = new CachingByteArraySource(this.source, 2); testee.getBytes("someClass"); testee.getBytes("someClass"); testee.getBytes("someClass"); verify(this.source, times(1)).getBytes("someClass"); }
public void run() { try { final MinionArguments paramsFromParent = this.dis .read(MinionArguments.class); Log.setVerbose(paramsFromParent.isVerbose()); final ClassLoader loader = IsolationUtils.getContextClassLoader(); final ClassByteArraySource byteSource = new CachingByteArraySource(new ClassloaderByteArraySource( loader), CACHE_SIZE); final F3<ClassName, ClassLoader, byte[], Boolean> hotswap = new HotSwap( byteSource); final MutationEngine engine = createEngine(paramsFromParent.engine, paramsFromParent.engineArgs); final MutationTestWorker worker = new MutationTestWorker(hotswap, engine.createMutator(byteSource), loader, paramsFromParent.fullMutationMatrix); final List<TestUnit> tests = findTestsForTestClasses(loader, paramsFromParent.testClasses, createTestPlugin(paramsFromParent.pitConfig)); worker.run(paramsFromParent.mutations, this.reporter, new TimeOutDecoratedTestSource(paramsFromParent.timeoutStrategy, tests, this.reporter)); this.reporter.done(ExitCode.OK); } catch (final Throwable ex) { ex.printStackTrace(System.out); LOG.log(Level.WARNING, "Error during mutation test", ex); this.reporter.done(ExitCode.UNKNOWN_ERROR); } }
public void run() { try { final MinionArguments paramsFromParent = this.dis .read(MinionArguments.class); Log.setVerbose(paramsFromParent.isVerbose()); final ClassLoader loader = IsolationUtils.getContextClassLoader(); final ClassByteArraySource byteSource = new CachingByteArraySource(new ClassloaderByteArraySource( loader), CACHE_SIZE); final F3<ClassName, ClassLoader, byte[], Boolean> hotswap = new HotSwap( byteSource); final MutationEngine engine = createEngine(paramsFromParent.engine, paramsFromParent.engineArgs); final MutationTestWorker worker = new MutationTestWorker(hotswap, engine.createMutator(byteSource), loader, paramsFromParent.fullMutationMatrix); final List<TestUnit> tests = findTestsForTestClasses(loader, paramsFromParent.testClasses, createTestPlugin(paramsFromParent.pitConfig)); worker.run(paramsFromParent.mutations, this.reporter, new TimeOutDecoratedTestSource(paramsFromParent.timeoutStrategy, tests, this.reporter)); this.reporter.done(ExitCode.OK); } catch (final Throwable ex) { ex.printStackTrace(System.out); LOG.log(Level.WARNING, "Error during mutation test", ex); this.reporter.done(ExitCode.UNKNOWN_ERROR); } }