Class TestOSGi

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
aQute.bnd.gradle.AbstractBndrun
aQute.bnd.gradle.TestOSGi
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

public class TestOSGi extends AbstractBndrun
OSGi Test task type for Gradle.

This task type can be used to execute tests in a bndrun file.

Here is examples of using the TestOSGi task type:

 import aQute.bnd.gradle.TestOSGi
 tasks.register("testOSGi", TestOSGi) {
   bndrun = resolveTask.flatMap { it.outputBndrun }
 }
 

Properties:

  • bndrun - This is the bndrun file to be tested. This property must be set.
  • bundles - The bundles to added to a FileSetRepository for non-Bnd Workspace builds. The default is "sourceSets.main.runtimeClasspath" plus "configurations.archives.artifacts.files". This must not be used for Bnd Workspace builds.
  • ignoreFailures - If true the task will not fail if the any test cases fail. Otherwise, the task will fail if any test case fails. The default is false.
  • workingDirectory - This is the directory for the test case execution. The default for workingDir is temporaryDir.
  • properties - Properties that are available for evaluation of the bnd instructions for non-Bnd Workspace builds. The default is the properties of the task and project objects. This must not be used for Bnd Workspace builds.
  • javaLauncher - Configures the default java executable to be used for execution.
  • resultsDirectory - This is the directory where the test case results are placed. The default is project.java.testResultsDir/name.
  • tests - The test class names to be run. If not set, all test classes are run. Use a colon (:) to specify a test method to run on the specified test class.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Task

    org.gradle.api.Task.Namer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Option to specify test names.

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a TestOSGi task.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.gradle.api.provider.Property<org.gradle.jvm.toolchain.JavaLauncher>
    Configures the default java executable to be used for execution.
    org.gradle.api.file.DirectoryProperty
    The directory where the test case results are placed.
    Return the test class names to be run.
    void
    Configures the test class names to be run.
    protected void
    worker(aQute.bnd.build.Project run)
    Test the Project object.

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getOnlyIf, getReasonNotToTrackState, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, prependParallelSafeAction, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, getConvention
  • Field Details

  • Constructor Details

    • TestOSGi

      public TestOSGi()
      Create a TestOSGi task.
  • Method Details

    • getResultsDirectory

      @OutputDirectory public org.gradle.api.file.DirectoryProperty getResultsDirectory()
      The directory where the test case results are placed.

      The default for resultsDirectory is "${project.java.testResultsDir}/${task.name}"

      Returns:
      The directory where the test case results are placed.
    • getTests

      @Input @Optional public List<String> getTests()
      Return the test class names to be run.
      Returns:
      The test class names to be run.
    • setTests

      public void setTests(List<String> tests)
      Configures the test class names to be run.
      Parameters:
      tests - The test class names to be run.
    • getJavaLauncher

      @Optional public org.gradle.api.provider.Property<org.gradle.jvm.toolchain.JavaLauncher> getJavaLauncher()
      Configures the default java executable to be used for execution.

      This java launcher is used if the bndrun does not specify the java property or specifies it with the default value java.

      Returns:
      The JavaLauncher property.
    • worker

      protected void worker(aQute.bnd.build.Project run) throws Exception
      Test the Project object.
      Specified by:
      worker in class AbstractBndrun
      Parameters:
      run - The Project object.
      Throws:
      Exception - If the worker action has an exception.