atlassian-test-base v0.1.8
Atlassian Test Base
The Atlassian Test Base is a test automation framework for Atlassian, which already includes basic functionalities for writing test programs.
Please start with Getting Started, Necessary Information and How to write tests to get a basic understanding.
You can find a commented example here
Getting Started
These instructions will get you set up to use atlassian-test-base
in your project.
- install
atlassian-test-base
npm install atlassian-test-base
- install cypress
npm install cypress --save-dev
Necessary Information
There are some information which are required when using this testbase. The following paragraph shows you how to obtain these information. 1. Basic URL of your Atlassian-website
https://example.atlassian.net
- An API token of your user profile
- log in to https://id.atlassian.com/manage-profile/security/api-tokens
- click Create API token
- from the dialog that appears, enter a memorable and concise Label for your token and click Create.
- click Copy to clipboard, then paste the token to your script or make sure to save it somewhere else
- Account ID of the website owner
- go on your Atlassian webside
- click on Teams
- click on Search for people and teams
- click on the person who owns the website
- now the URL should have this format:
JIRA: https://example.atlassian.net/jira/people/AccountID Confluence: https://example.atlassian.net/wiki/people/AccountID
- copy and save the ID
How to write tests
The following paragraph shows you how to implement your testcases using the test base. 1. The first and last lines of your code will always be the same. 1. You have to import the testbase. This should be the first line.
```ts
import {Testbase} from "atlassian-test-base";
```
2. In your second line, you need to initialize the testbase. The [Atlassian URL](#necessary-information) and your [API token](#necessary-information) is required here.
```ts
let testbase = new Testbase("yourWebsiteURL", "API token")
```
3. The last line always executes the testbase:
```ts
testbase.executeTestcases("all")
```
In this example we execute "all" testcases we have.
In summary, the basic format should look like this:
import {Testbase} from 'atlassian-test-base';
let testbase = new Testbase("yourWebsiteURL", "API token");
// Here you will leter implement your Testcases
testbase.executeTestcases("all")
- Create your test cases.
In this testbase, test cases are structured as a collection of different teststeps.
- First of all, you need to create a new, empty testcase with a name and a description:
testbase.createTestcase("testcase name", "description");
- Now you can add different teststeps to the created testcase. To keep it simple, we will only use the already implemented teststep to create a Jira-Project. (you can find a list of all implemented teststeps in All functionalities). You add the teststep with the following line:
testbase.addTeststep("testcase name", testbase.jira.Project().Create(parameter))
- First of all, you need to create a new, empty testcase with a name and a description:
Now, when you put it all together, your code should look like this:
import {Testbase} from 'atlassian-test-base'; let testbase = new Testbase("yourWebsiteURL", "API token"); testbase.createTestcase("testcase name", "description"); testbase.addTeststep("testcase name", testbase.jira.Project().Create(parameter)) testbase.executeTestcases("all")
You can find a working example here.
All functionalities
Testcases
Each testcase consists of several teststeps. It can also be assigned to categories to sort and seperate many different testcases.
create a testcase
testbase.createTestcase("Test1","my first test", "example")
This function creates a new testcase with the name Test1
, the description my first test
and the category example
. Node: A test case can have an infinite number of categories
add teststeps to your testcase
testbase.addTeststep("Test1", testbase.jira.Project().create(parameter))
This function adds the teststep to Test1
which creates a Jira project.
addbefore
testbase.addBefore("Test1", testbase.jira.Project().create(parameter))
This function adds a teststep which is executed before the specific testcase. It is not included in the report.
addbeforeEach
testbase.addBeforeEach(testbase.jira.Project().create(parameter))
This function adds a teststep which is executed before every testcase. It is not included in the report.
addAfter
testbase.addAfter("Test1", testbase.jira.Project().create(parameter))
This function adds a teststep which is executed after the specific testcase. It is not included in the report.
addAfterEach
testbase.addAfterEach(testbase.jira.Project().create(parameter))
This function adds a teststep which is executed after every testcase. It is not included in the report.
Teststeps
There are 3 types of already implemented teststeps. The Jira
,Confluence
and SessionHandler
teststep. Each of them has its own subordinate functionalities and can be called seperately.
For example, if you want to get the teststep which creates a new Jira project you need to type the following line:
testbase.jira.Project().create(parameter)
Note: "parameter" represents the parameter which are necessary for a Jira projekt. You can read about the Jira-parameter here and about the Confluence-Parameter here
functionality | subordinate functionality |
---|---|
Jira | Project IssueFieldvalue |
Confluence | Blog Post Page Space Object Attribute |
SessionHandler | login SaveSession |
Each subordinate functionality of Jira
and Confluence
implements the CRUD functionalities (create, read, update and delete)
Custom teststeps
This software is designed to work with Cypress and offers the ability to implement your own custom Cypress specs. You can find a tutorial for Cypress here.
If you have written your specs, add them with the special teststep cypress()
which is made for running cypress specs
testbase.addTeststep("Test1", testbase.cypress("path/to/your/spec.ts"))
In this example we are adding spec.ts
as a teststep to Test1
.
Execution of test cases
testbase.executeTestcases("example")
This function executes every testcase which has the category example
. After the execution, a report will be created automatically.
Test report
After each execution, a report is created and can be found in in reports
. Each testbase will only have one corresponding report file. The report for the first execution will be called "TestResult--1", the report for the second execution "TestResult--2" and so on. This also works with report files with custom names.
Furthermore, it is possible to create multiple reports with the same name for independent testbases in one programm. In this case, the report names from the second report on will be specified as "TestResult-(number of copies)". All reports are created automatically and have a special xml-Format, so you can import them with Jira-Cloud-Xray.
Note: Old report files will not be overwritten.
Changing the report file target path
testbase.changeXMLReportDestination("/.../filename.xml")
If you want to change the folder where the reports are saved in, you can use this method and declare the new path. The xml suffix is not needed and will be added automatically if it has not been included.
Additional information
- further explanation for the teststep parameter is coming soon. For now, please use the explanation linked in
Teststeps