use of de.dagere.peass.measurement.dependencyprocessors.DependencyTester in project peass by DaGeRe.
the class TestParallelMeasurement method testFiles.
@Test
public void testFiles() throws Exception {
try (MockedStatic<VersionControlSystem> mockedVCS = Mockito.mockStatic(VersionControlSystem.class);
MockedStatic<ExecutorCreator> mockedExecutor = Mockito.mockStatic(ExecutorCreator.class);
MockedStatic<GitUtils> gitUtils = Mockito.mockStatic(GitUtils.class)) {
VCSTestUtils.mockGetVCS(mockedVCS);
VCSTestUtils.mockGoToTagEmpty(gitUtils);
final PeassFolders folders = new PeassFolders(folder.getRoot());
final MeasurementConfig configuration = new MeasurementConfig(4, "2", "1");
configuration.setMeasurementStrategy(MeasurementStrategy.PARALLEL);
MavenTestExecutorMocker.mockExecutor(mockedExecutor, folders, configuration);
DependencyTester spiedTester = createTesterNoThreads(folders, configuration);
spiedTester.evaluate(TestDependencyTester.EXAMPLE_TESTCASE);
TestDependencyTester.checkResult(folders);
}
}
use of de.dagere.peass.measurement.dependencyprocessors.DependencyTester in project peass by DaGeRe.
the class TestParallelMeasurement method createTesterNoThreads.
/**
* Creates a tester that does not use Threads; this is necessary since mockito inline does not allow static mocks in Threads
* @param folders
* @param configuration
* @return
* @throws IOException
* @throws InterruptedException
*/
private DependencyTester createTesterNoThreads(final PeassFolders folders, final MeasurementConfig configuration) throws IOException, InterruptedException {
final DependencyTester tester = new DependencyTester(folders, configuration, new EnvironmentVariables());
DependencyTester spiedTester = Mockito.spy(tester);
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
ParallelExecutionRunnable[] runnables = invocation.getArgument(0);
for (ParallelExecutionRunnable runnable : runnables) {
runnable.run();
}
return null;
}
}).when(spiedTester).runParallel(Mockito.any());
return spiedTester;
}
use of de.dagere.peass.measurement.dependencyprocessors.DependencyTester in project peass by DaGeRe.
the class TestDependencyTester method testFiles.
@Test
public void testFiles() throws Exception {
try (MockedStatic<VersionControlSystem> mockedVCS = Mockito.mockStatic(VersionControlSystem.class);
MockedStatic<ExecutorCreator> mockedExecutor = Mockito.mockStatic(ExecutorCreator.class);
MockedStatic<GitUtils> utils = Mockito.mockStatic(GitUtils.class)) {
VCSTestUtils.mockGetVCS(mockedVCS);
final PeassFolders folders = new PeassFolders(folder.getRoot());
final MeasurementConfig configuration = new MeasurementConfig(4, "2", "1");
VCSTestUtils.mockExecutor(mockedExecutor, folders, configuration);
final DependencyTester tester = new DependencyTester(folders, configuration, new EnvironmentVariables());
tester.evaluate(EXAMPLE_TESTCASE);
checkResult(folders);
}
}
Aggregations