Skip to content

How to run test cases with AWS Greengrass Testing Framework locally

Rafe Luan edited this page Nov 30, 2022 · 2 revisions

AWS Greengrass Testing Framework uses maven as the build system, it also builds a uber java jar that can be executed on any JVM installed machine. Currently, we only support Unix system and Windows. We are offering 2 ways for developer to run test cases with AWS Greengrass Testing Framework locally, as following:

Run with Java jar

One way to run test locally is to package them together in uber jar and run the jar.

  1. The command to create the uber jar(standalone jar) with all the common steps and test cases: mvn clean package
  2. Provide aws credentials through either one of below ways:
    1. Environment variables
    2. System properties
    3. Command line arguments
  3. Download Greengrass Nucleus archive from here.
  4. Update test log path, Greengrass Nucleus archive path and location of standalone jar in the below command to run all the test cases: java -Dggc.archive=<archive_path> -Dtest.log.path=<test_result_path> -jar <uber_jar_path>
  5. If selected test cases needs to be run then -Dtags can be specified with the tag marked on top of test case: java -Dggc.archive=<archive_path> -Dtest.log.path=<test_result_path> -Dtags=<tag> -jar <uber_jar_path>

Run with Maven command

Another way is to use maven commands to run the test case.

  1. Add an execution flow like following to the pom.xml of your test module. Example.
                    <execution>
                        <id>feature-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <target>
                                <echo message="Feature Test Suite"/>
                                <java classname="com.aws.greengrass.testing.launcher.TestLauncher"
                                      fork="true"
                                      failonerror="true"
                                      newenvironment="true"
                                      classpathref="maven.test.classpath">
                                    <!--sysproperty key="ggc.archive" value="aws.greengrass.nucleus.zip"/>-->
                                    <sysproperty key="ggc.archive" value="greengrass-nucleus-latest.zip"/>
                                    <!--uncomment it if the install root directory is pointing to User directory instead of C drive-->
                                    <!--<sysproperty key="ggc.install.root" value="C:\"/>-->
                                </java>
                            </target>
                        </configuration>
                    </execution>
  1. Update the path of your sub-module and run the command mvn clean -DskipTests=false -pl <path_to_your_test_module> -am integration-test. For more information refer README.