🕓 15 minutes
How to create, run and analyse tests for the application components in the CodeNow environment.
- Writing tests for the application is an essential part of the application development process.
- Here are some benefits that you gain by testing your application:
- You don’t have to spend the time manually testing the code yourself.
- You can make changes to the code without worrying if something is broken.
- If something went wrong, you are able to detect the problematic part by looking into the tests.
- Tests provide documentation for what your code is actually meant to do.
CodeNow uses the Karate tool for testing purposes.
- If you want to read more about the Karate tool, see: https://github.com/intuit/karate
Find the "Testing&Quality Management" section in the sidebar menu, click on the "Testing" and go to the "Test Use Cases" option.
- Here you will see two sections:
- Select an Application
- You can select an existing application to create, run or analyse test use cases.
- Custom Applications
- You can create test cases for an external application.
- Select an Application
- Select an existing application and click on the "Add Test Repository" button on the right.
- After a little while, the "Show Test Use Case" button will appear.
- Click on the "Show Test Use Case".
- Here you will see some information regarding the existing tests for the selected application.
- How to clone your test repository
- Test components' builds.
- Test folders for each of the application components.
- The "Clone your Test Repository" section describes how to clone a test repository using SSH or via HTTP(S) into the local environment.
- The "Component Builds" section shows all the existing components inside the chosen application.
- For each test component, you can see the latest test package build version.
- If the test package of the particular component hasn't been built yet, you can click on the "Build" button on the right.
- You need to compile the sources in order to build the components which could be used by the end consumer.
- Down below you see all the test packages for every application component.
- It shows the test name and count.
- If you click on the "Detail" button, you can see the use case detail, tests and test results.
- If you click on the "Detail" button in the "Use Case Tests" section, in the "Feature Content" section you can see the test code for the selected test case.
- If you want to run the selected test package, you can click on the "Run" button.
- You will be redirected to a page, where you should select an environment and a use case version.
- Then click on the "Deploy" button.
CodeNow uses the Cucumber tool to generate test reports.
- If you want to know more about the Cucumber, see : https://cucumber.io/
To see the test results analysis:
- Select the application component.
- Click on the "Details" button on the right and you will be redirected to a Use Case Detail page.
- In the section "Use Case Test Results" select one of the test results and click the "Details" button.
Here, you are able to see an analysis of the features, tags, steps and failures on the selected use case run report.
- The graphs in this page show the passing and failing statistics for features.
- The table shows detailed information for the tested feature including:
- Passed, failed, skipped, pending and undefined steps.
- Passed and failed scenarios.
- Duration and status for the features.
- The graph shows passing and failing statistics for tags.
- The detailed information on each tag is collected into the table below the graph.
- The following table shows the step statistics for this build.
- The list below is based on the results. If a step does not provide information about the result then it is not listed below.
- Additionally, @Before and @After are not counted because they are part of the scenarios, not steps.
- The following summary displays the scenarios that failed.
If you want to test an external application that doesn't run in the CodeNow environment, you can add a custom test application for this purpose.
Fill in the application name and add the required number of components. Then click on the "Confirm" button.
Now you can clone the created test repository to the local environment, write tests and run them in the CodeNow environment.
- Don't forget to add correct values, so the tests can reach your application.
- The process continues with STEP 2 of the "Select an Existing Application" section.
- Feature: List of scenarios.
- Scenario: Business rule through a list of steps with arguments.
- Given: Some precondition step
- When: Some key actions
- Then: To observe outcomes or validation
- And,But: To enumerate more Given,When,Then steps
- Examples: Container for a table
- Background: List of steps run before each of the scenarios
- This simple test example consists of two parts:
- The first test creates a new cat entity with the name of "Fluffy". It says: after making a POST request, you should get status 201 and the response must contain a non-null id and the name "Fluffy".
- The second one is a simple GET for a cat that was created in a previous part of the test.
- If you are creating a test for a CodeNow component, then you don’t need to specify the given url or path. The CodeNow will automatically add the right values during the building process.
- On the other hand, if you create a test package and write a test for a custom application, then for the test to be able to reach its testing target, you must specify the "given url" value.
See our other manuals: