Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This page provides

Excerpt

some hints for using the Eclipse TPTP facilities with Groovy

.

The Eclipse Testing and Performance Tools Platform (TPTP) project addresses the entire test and performance life cycle, from early testing to production application monitoring, including test editing and execution, monitoring, tracing and profiling, and log analysis. It is primarily aimed at the Java-aware tester but can also be used with Groovy.

As one example, if you follow the introductory tutorial included in the TPTP documentation called: Creating a datapool driven JUnit test application, you will create a datapool application which lets you invoke data-driven JUnit tests. If you simply replace the Java code with Groovy code you can have data-driven Groovy tests. Here is what your test might look like:

Code Block
import org.eclipse.hyades.models.common.datapool.impl.Common_DatapoolFactoryImpl;

class Groovy_TPTP extends GroovyTestCase {
    def dpIterator

    void setUp() throws Exception {
        def dpFactory = new Common_DatapoolFactoryImpl()
        def datapool = dpFactory.load(new java.io.File("GIA_TPTP\\shoppingCartDatapool.datapool"),false)
        dpIterator = dpFactory.open(datapool,"org.eclipse.hyades.datapool.iterator.DatapoolIteratorSequentialPrivate")
        dpIterator.dpInitialize(datapool,0)
    }

    void testShoppingCartConstructor() {
        def cart = new MyShoppingCart()
        while(!dpIterator.dpDone()) {
            def description = dpIterator.dpCurrent().getCell("Description").stringValue
            def expectedPrice = dpIterator.dpCurrent().getCell("Price").doubleValue
            def actualPrice = cart.myFlowers[description]
            assertNotNull(actualPrice)
            assertEquals(expectedPrice, actualPrice.doubleValue())
            dpIterator.dpNext()
        }
    }
}

Here is what your output might look like:

In addition to allowing you to write datapool-aware Groovy tests, by making use of GroovyTestSuite and AllTestSuite you can visually select Groovy test cases to run within TPTP using its looping and selection features. This lets non-Groovy aware team members create new test cases from primitives which Groovy-aware team members can create.

For more details, see GINA or the TPTP web site.