private void handleTestEnd(final SafeDataInputStream is) { final Description d = is.read(Description.class); final int numberOfResults = is.readInt(); final Set<BlockLocation> hits = new HashSet<>(numberOfResults); for (int i = 0; i != numberOfResults; i++) { readProbeHit(is, hits); } this.handler.apply(createCoverageResult(is, d, hits)); }
private void recordTestCoverage(final int executionTime, final int classId, final int probeNumber, final boolean testPassed) { when(this.is.readInt()).thenReturn(classId, executionTime); when(this.is.readString()).thenReturn("foo"); this.testee.apply(Id.CLAZZ, this.is); when(this.is.read(Description.class)).thenReturn(this.description); when(this.is.readInt()).thenReturn(1); when(this.is.readLong()).thenReturn(1l, CodeCoverageStore.encode(classId, probeNumber)); when(this.is.readBoolean()).thenReturn(testPassed); this.testee.apply(Id.OUTCOME, this.is); }
@Test public void shouldSendDetectionStatus() throws IOException { final MutationIdentifier mi = aMutationId().withIndex(0).withMutator("foo") .build(); final MutationStatusTestPair ms = new MutationStatusTestPair(2, DetectionStatus.KILLED, "foo"); this.testee.report(mi, ms); final SafeDataInputStream is = resultToStream(); assertEquals(Id.REPORT, is.readByte()); assertEquals(is.read(MutationIdentifier.class), mi); assertEquals(is.read(MutationStatusTestPair.class), ms); }
private void handleDescribe(final SafeDataInputStream is) { final MutationIdentifier mutation = is.read(MutationIdentifier.class); this.idMap.put(mutation, MutationStatusTestPair.notAnalysed(1, DetectionStatus.STARTED)); }
@Test public void shouldSendMutationIdentifierToOutputStream() throws IOException { final MutationIdentifier mi = aMutationId().withIndex(0).withMutator("foo") .build(); this.testee.describe(mi); final SafeDataInputStream is = resultToStream(); assertEquals(Id.DESCRIBE, is.readByte()); assertEquals(is.read(MutationIdentifier.class), mi); }
@Before public void setup() { MockitoAnnotations.initMocks(this); this.mutations = new ArrayList<>(); this.tests = new ArrayList<>(); this.args = new MinionArguments(this.mutations, this.tests, "anEgine", EngineArguments.arguments(), this.timeoutStrategy, false, false, TestPluginArguments.defaults()); when(this.is.read(MinionArguments.class)).thenReturn(this.args); when(this.engine.createMutator(any(ClassByteArraySource.class))) .thenReturn(this.mutater); final MutationEngineFactory factory = Mockito.mock(MutationEngineFactory.class); when(factory.createEngine(any(EngineArguments.class))).thenReturn(this.engine); when(this.settings.createEngine(any(String.class))).thenReturn(factory); this.testee = new MutationTestMinion(this.settings, this.is, this.reporter); }
s.getInputStream()); final CoverageOptions paramsFromParent = dis.read(CoverageOptions.class);
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); } }
s.getInputStream()); final CoverageOptions paramsFromParent = dis.read(CoverageOptions.class);
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); } }