[antlr-interest] maven & gunit - Gunit tests don't run

Selena Phillips selenareneephillips at gmail.com
Sat Jul 14 15:06:39 PDT 2012


I cannot get GUint tests to run in my maven setup. When I run mvn compile,
everything compiles fine. The lexer and parser classes are generated as
expected in target/generated-sources. However, when running mvn tests, all
the junit tests run and I get this output:

-----------------------------------------------------------
 G U N I T   R E S U L T S
-----------------------------------------------------------

Summary :
Tests run: 0,  Failures: 0,  Invalid: 0

The gunit report folder is created, but is empty. There are no error
messages or exceptions reported.

Directory structure:

src

   - main
      - antlr3
         - org.companyname.projectname.parser
         - groovy
         - org.companyname.projectname
            - data
            - logic
            - util
            - xml
         - test
      - groovy
         - org.companyname.projectname
            - logic
            - util
            - xml
         - resources
         - org.companyname.projectname
      - gunit
         - org.companyname.projectname.parser
            - GrammarName.gunit


Here is my POM setup:

  <dependencies>
    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>3.4</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>gunit</artifactId>
      <version>3.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>antlr3-maven-plugin</artifactId>
      <version>3.4</version>
    </dependency>
    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>maven-gunit-plugin</artifactId>
      <version>3.4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/target/generated-sources/antlr3</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.antlr</groupId>
        <artifactId>antlr3-maven-plugin</artifactId>
        <version>3.4</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>antlr</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.antlr</groupId>
        <artifactId>maven-gunit-plugin</artifactId>
        <version>3.4</version>
        <executions>
          <execution>
          <id>maven-gunit-plugin</id>
            <phase>test</phase>
            <goals>
              <goal>gunit</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

There are just a few simple tests in the gUnit file for a simple grammar:

gunit Testy;

qualifiedName:
"helloWorld" OK

IDENTIFIER:
"abc123" OK
"abc*%123" OK
"123abc" FAIL

Here is an excerpt from my grammar:

grammar GrammarName;

options {
    language = Java;
}

@lexer::header {
  package org.companyname.projectname.parser;
}

@parser::header {
  package org.companyname.projectname.parser;
}

qualifiedName
    :   IDENTIFIER ('.' IDENTIFIER)*
    ;

IDENTIFIER
    :   IDENTIFIER_CHARS*
    ;

fragment
IDENTIFIER_CHARS
    :    (IDENTIFIER_START) (IDENTIFIER_PART)*
    ;

fragment
IDENTIFIER_START
    :   '\u0024'
    |   '\u0041'..'\u005a'
    |   '\u005f'
...... (Way too long to repeat here.)

fragment
IDENTIFIER_PART
    :   '\u0000'..'\u0008'
    |   '\u000e'..'\u001b'
    |   '\u0024'
    |   '\u0030'..'\u0039'
........(Ditto)


More information about the antlr-interest mailing list