use of org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider in project tycho by eclipse.
the class TestMojo method createEclipseInstallation.
private EquinoxInstallation createEclipseInstallation() throws MojoExecutionException {
DependencyResolver platformResolver = dependencyResolverLocator.lookupDependencyResolver(project);
final List<Dependency> extraDependencies = getExtraDependencies();
List<ReactorProject> reactorProjects = getReactorProjects();
final DependencyResolverConfiguration resolverConfiguration = new DependencyResolverConfiguration() {
@Override
public OptionalResolutionAction getOptionalResolutionAction() {
return OptionalResolutionAction.IGNORE;
}
@Override
public List<Dependency> getExtraRequirements() {
return extraDependencies;
}
};
DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project, null, reactorProjects, resolverConfiguration);
if (testRuntimeArtifacts == null) {
throw new MojoExecutionException("Cannot determinate build target platform location -- not executing tests");
}
work.mkdirs();
EquinoxInstallationDescription testRuntime = new DefaultEquinoxInstallationDescription();
testRuntime.setDefaultBundleStartLevel(defaultStartLevel);
testRuntime.addBundlesToExplode(getBundlesToExplode());
testRuntime.addFrameworkExtensions(getFrameworkExtensions());
if (bundleStartLevel != null) {
for (BundleStartLevel level : bundleStartLevel) {
testRuntime.addBundleStartLevel(level);
}
}
TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
createSurefireProperties(provider);
for (ArtifactDescriptor artifact : testRuntimeArtifacts.getArtifacts(ArtifactType.TYPE_ECLIPSE_PLUGIN)) {
// note that this project is added as directory structure rooted at project basedir.
// project classes and test-classes are added via dev.properties file (see #createDevProperties())
// all other projects are added as bundle jars.
ReactorProject otherProject = artifact.getMavenProject();
if (otherProject != null) {
if (otherProject.sameProject(project)) {
testRuntime.addBundle(artifact.getKey(), project.getBasedir());
continue;
}
File file = otherProject.getArtifact(artifact.getClassifier());
if (file != null) {
testRuntime.addBundle(artifact.getKey(), file);
continue;
}
}
testRuntime.addBundle(artifact);
}
Set<Artifact> testFrameworkBundles = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
for (Artifact artifact : testFrameworkBundles) {
DevBundleInfo devInfo = workspaceState.getBundleInfo(session, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), project.getPluginArtifactRepositories());
if (devInfo != null) {
testRuntime.addBundle(devInfo.getArtifactKey(), devInfo.getLocation(), true);
testRuntime.addDevEntries(devInfo.getSymbolicName(), devInfo.getDevEntries());
} else {
File bundleLocation = artifact.getFile();
ArtifactKey bundleArtifactKey = getBundleArtifactKey(bundleLocation);
testRuntime.addBundle(bundleArtifactKey, bundleLocation, true);
}
}
testRuntime.addDevEntries(getTestBundleSymbolicName(), getBuildOutputDirectories());
reportsDirectory.mkdirs();
return installationFactory.createInstallation(testRuntime, work);
}
use of org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider in project tycho by eclipse.
the class TestMojo method createProvisionedInstallation.
private EquinoxInstallation createProvisionedInstallation() throws MojoExecutionException {
try {
TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
createSurefireProperties(provider);
ProvisionedInstallationBuilder installationBuilder = provisionedInstallationBuilderFactory.createInstallationBuilder();
Set<Artifact> testHarnessArtifacts = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
for (Artifact testHarnessArtifact : testHarnessArtifacts) {
installationBuilder.addBundleJar(testHarnessArtifact.getFile());
}
RepositoryReferences sources = repositoryReferenceTool.getVisibleRepositories(project, session, RepositoryReferenceTool.REPOSITORIES_INCLUDE_CURRENT_MODULE);
installationBuilder.addMetadataRepositories(sources.getMetadataRepositories());
installationBuilder.addArtifactRepositories(sources.getArtifactRepositories());
installationBuilder.setProfileName(profileName);
installationBuilder.addIUsToBeInstalled(getIUsToInstall(testHarnessArtifacts));
File workingDir = new File(project.getBuild().getDirectory(), "p2temp");
workingDir.mkdirs();
installationBuilder.setWorkingDir(workingDir);
installationBuilder.setDestination(work);
return installationBuilder.install();
} catch (Exception ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
use of org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider in project tycho by eclipse.
the class ProviderHelper method selectProvider.
public TestFrameworkProvider selectProvider(List<ClasspathEntry> classpath, Properties providerProperties, String providerHint) throws MojoExecutionException {
if (providerHint != null) {
TestFrameworkProvider provider = providers.get(providerHint);
if (provider == null) {
throw new MojoExecutionException("Could not find test framework provider with role hint '" + providerHint + "'. Available providers: " + providers.keySet());
} else {
return provider;
}
}
List<TestFrameworkProvider> candidates = new ArrayList<>();
for (TestFrameworkProvider provider : providers.values()) {
if (provider.isEnabled(classpath, providerProperties)) {
candidates.add(provider);
}
}
validateCandidates(candidates);
TestFrameworkProvider highestVersionProvider = Collections.max(candidates, VERSION_COMPARATOR);
validate(highestVersionProvider, providerProperties);
return highestVersionProvider;
}
use of org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider in project tycho by eclipse.
the class ProviderHelperTest method testSelectTestNG.
public void testSelectTestNG() throws Exception {
TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.testng:6.9.12"), new Properties(), null);
assertEquals(TestNGProvider.class, provider.getClass());
}
use of org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider in project tycho by eclipse.
the class ProviderHelperTest method testSelectJunit4.
public void testSelectJunit4() throws Exception {
TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.junit:4.8.1"), new Properties(), null);
assertEquals(JUnit4Provider.class, provider.getClass());
}
Aggregations