Version 35

     

     

     

    -


     

     

    Tools support (ANT / Maven)

     

    Implementation should be common for tools support and enable easy plugin/use in specific build system. JBoss Unit provides configuration XML file that set up test definitions. The tools support should setup state based on this file and then enable specific actions invocations. Three main are:

    • Read config and setup state

    • Execute tests based on filter criteria. This is based on names, keywords and etc. It should support excludes (like run all besides...).

    • Generate reports (html, xml and etc.)

     

    Use cases to cover:

    • Run everything

    • Run everything besides ... (names, keywords...)

    • Run a single test

    • Run a set of tests (names, keywords)

    • Filter tests to run based on criteria

    • Generate console reports

    • Generate HTML reports

    • Generate XML reports

     

    Two main to implement are ant and maven. The implementation should enable to run based on parameters from command line. For ant or maven it means that it should be possible to pass params using -D switch and those will overrite setup in build files.

     

    Command line execution:

     

    java [proper_class_path_here] org.jboss.unit.tools.Main --config=config/jboss-unit.xml \
                                                            --ids=testOne,testTwo,testThree \
                                                            --keywords=APITests,TCK \
                                                            --property.name=value \
                                                            --property.name2=value2 \
                                                            --properties=[name3=value1,name3,value2] \  
                                                            --parameter.name=[value1,value2,value3] \   
                                                            --parameter.name2=value \                   
                                                            --parameters=[a=b,a=b2,c=d] \               
    
    java [proper_class_path_here] org.jboss.unit.tools.Main --help    [NOT YET IMPLEMENTED]
    

     

    Note: if you put the same properties in both --property and --properties its not predictable which value will be used

     

    Ant support

     

     

    Setup in buildfile:

     

    <jboss-unit jpda="false" jpdaPort="9000" jpdaSuspend="true" failOnError="false" assertions="true">
       <!-- "tests" tags group test cases for single execution -->
    
       <!-- define and execute several test based on filters during a single Runner.execute() call -->
       <tests config="path/jboss-unit1.xml">
          
          <!-- executed tests will be based on sum of all applied filters -->
          <!-- exclude filters will take precedence during conditions check -->
    
          <include ids="test1,test2,test3" keywords="key1, key2, key3"></include>
          <include id="test55" ></include>
          <include ... ></include>
     
          <exclude ids="biltoTest,oldTest,loloTest" keywords="outdated, examples"></exclude>
          <exclude ... ></exclude>
    
          <!-- include single test using its id --> 
          <include id="bilto"></include>
          <include id="boboTest1></include>
          
          <exclude id="lolo" ></exclude>
           
          <!-- reports specified for specific <tests> override global -->
          <reports noconsole="true">
             <html dir="">
             <!-- console is enabled by default so this turns it off -->
             </noconsole>
          </reports>
    
    
       </tests>
    
       
       <tests config="path/jboss-unit2.xml">
          <include id="singleTest1"></include>
          <include id="singleTest2"></include>
       </tests/
        
       <!-- generates reports for all invoked tests -->
       <reports>
          <xml toDir="">
          <html toDir="">
       </reports>
       
    </jboss-unit>
    

     

    Maven support

     

             <plugin>
                <groupId>org.jboss.unit</groupId>
                <artifactId>jboss-unit-tooling-maven2</artifactId>
                <version>1.2.0-SNAPSHOT</version>
                <executions>
                   <execution>
                      <phase>test</phase>
                      <goals>
                         <goal>execute</goal>
                      </goals>
                   </execution>
                </executions>
                <configuration>
                   
                   <!--Uncomment if needed-->
                   <!--<jpda>false</jpda>-->
                   <!--<jpdaPort>9000</jpdaPort>-->
                   <!--<jpdaSuspend>true</jpdaSuspend>-->
                   <!--<failOnError>false</failOnError>-->
                   <!--<assertions>true</assertions>-->
    
                   <testsuites>
                      <testsuite>
                         <config>jboss-unit.xml</config>
                         <includes>
                            <include>
                               <ids>
                                  <id>testOne</id>
                                  <id>testTwo</id>
                               </ids>
                               <keywords>
                                  <keyword>keyword1</keyword>
                                  <keyword>keyword2</keyword>
                               </keywords>
                            </include>
                         </includes>
                         <excludes>
                            <exclude>
                               <ids>
                                  <id>otherTestOne</id>
                                  <id>otherTestTwo</id>
                               </ids>
                               <keywords>
                                  <keyword>otherKeyword1</keyword>
                                  <keyword>otherKeyword2</keyword>
                               </keywords>
                            </exclude>
                         </excludes>
                         <parameters>
                            <parameter>
                               <name>parameter1</name>
                               <values>
                                  <value>value1</value>
                                  <value>value2</value>
                               </values>
                            </parameter>
                            <parameter>
                               <name>parameter2</name>
                               <values>
                                  <value>value3</value>
                                  <value>value4</value>
                               </values>
                            </parameter>
                         </parameters>
                         <properties>
                            <property>
                               <name>sampleProperty</name>
                               <value>propertyValue</value>
                            </property>
                         </properties>
                      </testsuite>
                   </testsuites>
                </configuration>
             </plugin>
    
    <!-- or the simplest configuration -->
             <plugin>
                <groupId>org.jboss.unit</groupId>
                <artifactId>jboss-unit-tooling-maven2</artifactId>
                <executions>
                   <execution>
                      <phase>test</phase>
                      <goals>
                         <goal>execute</goal>
                      </goals>
                   </execution>
                </executions>
                <configuration>
    
                   <testsuites>
                      <testsuite>
                         <config>local-jboss-unit.xml</config>
                      </testsuite>
                   </testsuites>
                   <reports>
                      <xml>target/tests/reports/xml</xml>
                      <html>target/tests/reports/html</html>
                   </reports>
                </configuration>
             </plugin>
    
    

     

    Parameters passed from command line:

     

    -Djboss.unit.properties.name1=value
    -Djboss.unit.properties=[name1=value1,name2=value2] 
    -Djboss.unit.parameter.a=[b,c,d]                                
    -Djboss.unit.parameter.e=f                                      
    -Djboss.unit.parameters=[name=value1,name=value2,name2=value]   
    
    # will invoke only those tests and skip all the other
    -Djboss.unit.tests=testOne,testTwo  
     
    -Djboss.unit.jpda=true
    -Djboss.unit.jpda.port=9999
    -Djboss.unit.jpda.suspend=true
    
    # will make jboss unit break the build (ant/maven) on testcase failure
    -Djboss.unit.failonerror=true
    

     

     

    TBD

     

    TODO

     

    • Remote debugging

      • --jpda option + additional configuration

    • Logging

      • Improve logging in tooling code (both ant plugin and MainBuilder)

      • Enable to switch between log4j and JUL

    • Commandline and ant configuration

      • -Djboss.unit.keywords=[key1,key2]

        - good behaviour how it overrides ant settings need to be defined

      • Change noconsole attribute to something better - useConsole ??

      • --help switch to print some info

      • --verbose switch (maybe...)

    • Documentation

      • Initial doc for commandline does not exist yet.

      • Ant

      • Maven

    • Maven

      • Initial maven plugin