Search in sources :

Example 1 with DependencyTester

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);
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) TestDependencyTester(de.dagere.peass.measurement.analysis.TestDependencyTester) DependencyTester(de.dagere.peass.measurement.dependencyprocessors.DependencyTester) GitUtils(de.dagere.peass.vcs.GitUtils) ExecutorCreator(de.dagere.peass.dependency.ExecutorCreator) VersionControlSystem(de.dagere.peass.vcs.VersionControlSystem) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.Test)

Example 2 with DependencyTester

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;
}
Also used : TestDependencyTester(de.dagere.peass.measurement.analysis.TestDependencyTester) DependencyTester(de.dagere.peass.measurement.dependencyprocessors.DependencyTester) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) ParallelExecutionRunnable(de.dagere.peass.measurement.dependencyprocessors.ParallelExecutionRunnable) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 3 with DependencyTester

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);
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) DependencyTester(de.dagere.peass.measurement.dependencyprocessors.DependencyTester) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) GitUtils(de.dagere.peass.vcs.GitUtils) ExecutorCreator(de.dagere.peass.dependency.ExecutorCreator) VersionControlSystem(de.dagere.peass.vcs.VersionControlSystem) PeassFolders(de.dagere.peass.folders.PeassFolders) Test(org.junit.Test)

Aggregations

DependencyTester (de.dagere.peass.measurement.dependencyprocessors.DependencyTester)3 MeasurementConfig (de.dagere.peass.config.MeasurementConfig)2 ExecutorCreator (de.dagere.peass.dependency.ExecutorCreator)2 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)2 PeassFolders (de.dagere.peass.folders.PeassFolders)2 TestDependencyTester (de.dagere.peass.measurement.analysis.TestDependencyTester)2 GitUtils (de.dagere.peass.vcs.GitUtils)2 VersionControlSystem (de.dagere.peass.vcs.VersionControlSystem)2 Test (org.junit.Test)2 ParallelExecutionRunnable (de.dagere.peass.measurement.dependencyprocessors.ParallelExecutionRunnable)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1