Search code examples
citrus-framework

Citrusframework - Include standard TestNG Test-Classes


I have a number of Citrus-Tests and all is working fine. But now I had the requirement to include a simple Unit-Test, hence I have added a very simple TestNG Test-Class and was expecting that this test gets executed along with the other Citrus-Tests.

When I execute the test manually
mvn clean test -Dtest=AppConfigParserTest
it works, but it's not included the global test-suite running all my CitrusTests. I have no idea how to make sure it's executed by default.

I created the test-class in src/test/java along with the other tests, just like this:

public class AppConfigParserTest {

  @Test
  public void testAppConfigParser() throws AppException, IOException {
  ....
  ....
  }
}

Maybe I missed that part in the documentation and hope someone can help.

Thanks,
Chris


Solution

  • It is hard to figure out why the test isn't working without knowing your setup but here are some points that may help you figure it out.

    Citrus tests are integration tests and they usually run with the maven-failsafe-plugin which expects a naming convention of MyPerfectTestIT ( the letters IT at the end). Since you are using maven, here is an example:

    <build>
        <plugins>
            <!-- disable running unit tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <!-- setup running integration tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <id>integration-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    My bet is that if you have configured the Citrus tests correctly, your unit test will never run with the integration test suite since they are two different types of tests AND are being executed by two different maven plugins. The unit tests should run separately before the integration tests.

    Check how your maven-surefire-plugin is configured.