Skip to content

Zerocode archetype to auto generate a maven testing project

authorjapps edited this page Nov 1, 2019 · 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=zerocode.archetype -DarchetypeArtifactId=zerocodeArchetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.xbox -DartifactId=game-app
Green Test

Commands

To install the archetype locally in your laptop:

Step 1)

  1. Navigate to zerocode-maven-archetype on your machine.
  2. Run mvn install from this directory

This generates zerocodeArchetype-1.0-SNAPSHOT.jar, which is then used for generating the new ready-made project. image

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=zerocode.archetype
    -DarchetypeArtifactId=zerocodeArchetype 
    -DarchetypeVersion=1.0-SNAPSHOT 
    -DgroupId=com.myproject 
    -DartifactId=zerocodeArchetypeTest"
  1. The generic command format is:
    "mvn archetype:generate -DarchetypeGroupId=<custom-archetype group id e.g. zerocode.archetype>
    -DarchetypeArtifactId=<custom-archetype artifactid e.g. zerocodeArchetype>
    -DarchetypeVersion=<custom-archetype version e.g. 1.0-SNAPSHOT>
    -DgroupId=<new project Group Id>
    -DartifactId=<new project artifact Id>"

The final command should look like below:

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

Optional step

This may not be needed for a real or live project. 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