Skip to content

Zerocode archetype to auto generate a maven testing project

authorjapps edited this page May 22, 2020 · 7 revisions
          Original Author Name: @kristin-smith

Background

A great time saver!

This archetype helps a developer or a Dev-In-Test automation-engineer to set up a working maven project quickly. Also, we can think of this archetype might help us to avoid any errors which could otherwise occur during setting up a project manually.

Sample CLI

mvn archetype:generate \
-DarchetypeGroupId=org.jsmart \
-DarchetypeArtifactId=zerocode-maven-archetype \
-DarchetypeVersion=1.3.20 \
-DgroupId=com.myproject \
-DartifactId=my-api-testing \
-Dversion=1.0.0-SNAPSHOT

Note:
Use the latest version instead of "1.3.20" if available. Check the release notes.
Release note link: https://github.com/authorjapps/zerocode/releases

OLD version:

$ mvn archetype:generate -DarchetypeGroupId=zerocode.archetype -DarchetypeArtifactId=zerocodeArchetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.xbox -DartifactId=game-app
Green Test

Step 2)

To generate a new archetype-based project:

  1. Navigate to the directory that will house the project.

e.g. a brand new folder or a new git repo.

  1. Run
mvn archetype:generate \
-DarchetypeGroupId=org.jsmart \
-DarchetypeArtifactId=zerocode-maven-archetype \
-DarchetypeVersion=1.3.20 \
-DgroupId=com.myproject \
-DartifactId=my-api-testing \
-Dversion=1.0.0-SNAPSHOT
  1. The generic command format is:
    "mvn archetype:generate -DarchetypeGroupId=<custom-archetype group id e.g. zerocode.archetype>
    -DarchetypeArtifactId=<custom-archetype artifactid e.g. zerocode-maven-archetype>
    -DarchetypeVersion=<custom-archetype version e.g. 1.3.20>
    -DgroupId=<new project Group Id e.g. com.mycompany>
    -DartifactId=<new project artifact Id e.g. my-api-e2e-testing>"

The final command should look like below:

$ mvn archetype:generate -DarchetypeGroupId=org.jsmart -DarchetypeArtifactId=zerocode-maven-archetype -DarchetypeVersion=1.3.20 -DgroupId=com.mycompany -DartifactId=my-api-e2e-testing

Optional step

The sample test scenario get_api_200 works fine i.e. the test turns green.

The other two samples "post" and "put" may not be relevant to your project, but can be used as a reference only or to manipulate with your payload/headers. The purpose of the above archetype is to generate a ready-made maven project to make it easy for a developer to start with automation.

Add personal GitHub token to test files:

  • In both post_api_200.json and put_api_200.json, substitute your own GitHub token for the placeholder.
  • In put_api_200.json, also update the name of the owner in the URL to your GitHub username

Blogs

Clone this wiki locally