Skip to content

Commit

Permalink
Refactoring cucumber adapter (#29)
Browse files Browse the repository at this point in the history
* Update workflow

* Refactoring formatter

* Refactoring storage

* Refactoring tags and fix bugs

* Refactoring mappers

* Refactoring utils and fix bugs

* Add index in types

* Remove unused

* Update Readme

* Update tsconfig

* Add files field, remove client, increment version

* Fix load autotests

* Fix zero mode

* Update version

---------

Co-authored-by: Max Zakharov <[email protected]>
  • Loading branch information
ZakharovUser and ZakharovUser authored Oct 2, 2023
1 parent b6390e9 commit 7c4cabd
Show file tree
Hide file tree
Showing 16 changed files with 548 additions and 571 deletions.
7 changes: 2 additions & 5 deletions testit-adapter-cucumber/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"plugins": ["@typescript-eslint"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
],
"prettier/prettier": "warn",
"@typescript-eslint/explicit-function-return-type": "error"
}
}
196 changes: 196 additions & 0 deletions testit-adapter-cucumber/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea
.idea/*

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

lib
dist
.npmrc
4 changes: 2 additions & 2 deletions testit-adapter-cucumber/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"endOfLine": "lf",
"printWidth": 80,
"printWidth": 120,
"semi": true,
"singleQuote": true,
"singleQuote": false,
"useTabs": false,
"trailingComma": "es5",
"tabWidth": 2
Expand Down
51 changes: 20 additions & 31 deletions testit-adapter-cucumber/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ npm install testit-adapter-cucumber

## Usage

### API client

To use adapter you need to install `testit-api-client`:
```
npm install testit-api-client
```

### Configuration

| Description | Property | Environment variable | CLI argument |
Expand All @@ -27,21 +20,17 @@ npm install testit-api-client
| ID of configuration in TMS instance [How to getting configuration ID?](https://github.com/testit-tms/.github/tree/main/configuration#configurationid) | configurationId | TMS_CONFIGURATION_ID | tmsConfigurationId |
| ID of the created test run in TMS instance | testRunId | TMS_TEST_RUN_ID | tmsTestRunId |

Create `testitFormatter.js` file in the root directory of the project:
```js
const { TestItFormatter } = require('testit-adapter-cucumber');

module.exports = class CustomFormatter extends TestItFormatter {
constructor(options) {
super(options, {
url: 'URL',
privateToken: 'USER_PRIVATE_TOKEN',
projectId: 'PROJECT_ID',
configurationId: 'CONFIGURATION_ID',
testRunId: 'TEST_RUN_ID',
});
}
};
Create `tms.config.json` file in the root directory of the project:
```json
{
"url": "Url",
"privateToken": "Private_token",
"projectId": "Project_id",
"configurationId": "Configuration_id",
"testRunName": "Test_run_name",
"adapterMode": 2,
"automaticCreationTestCases": false
}
```

And fill object with your configuration. Formatter sends results to Test IT.
Expand All @@ -53,7 +42,7 @@ Add to `cucumber.js` file
```js
module.exports = {
default:
'-f ./testitFormatter.js',
'-f testit-adapter-cucumber',
};
```

Expand Down Expand Up @@ -92,9 +81,9 @@ Cucumber tags can be used to specify information about autotest.
- `@Title` - Title that is displayed on autotest page
- `@DisplayName` - Name that is displayed in autotests table
- `@Description` - Autotest description
- `@Link` - can be specified either in JSON (`@Link={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}`) or in text (`@Link=http://google.com`)
- `@Label` - Label that is going to be linked to autotest
- `@WorkItemId` - Work item's ID to which autotest is going to be linked
- `@Links` - can be specified either in JSON (`@Link={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}`) or in text (`@Link=http://google.com`)
- `@Labels` - Label that is going to be linked to autotest
- `@WorkItemIds` - Work item's ID to which autotest is going to be linked
- `@NameSpace` - directory in the TMS system
- `@ClassName` - subdirectory in the TMS system

Expand All @@ -106,16 +95,16 @@ Feature: Tags
@DisplayName=GoogiliGoogle
@Description=Cannot_Write_With_Spaces
@ExternalId=344
@Link=http://google.com
@Link=http://vk.com
@Label=Maths
@Label=School
@Links=http://google.com
@Links=http://vk.com
@Labels=Maths
@Labels=School
Scenario: Scenario with links
When 2+2
Then Result is 4
@Title=LINKS
@ExternalId=343
@Link={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}
@Links={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}
Scenario: Scenario with link obj
When 2+2
Then Result is 4
Expand Down
9 changes: 6 additions & 3 deletions testit-adapter-cucumber/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testit-adapter-cucumber",
"version": "1.1.7",
"version": "2.0.0",
"description": "Cucumber adapter for Test IT",
"main": "dist/formatter.js",
"scripts": {
Expand All @@ -22,7 +22,7 @@
"dependencies": {
"@cucumber/cucumber": "^7.3.1",
"@cucumber/messages": "^17.1.1",
"testit-api-client": "^1.0.8"
"testit-js-commons": "^1.1.5"
},
"devDependencies": {
"@babel/preset-env": "^7.15.8",
Expand All @@ -48,5 +48,8 @@
"type": "git",
"url": "git+https://github.com/testit-tms/adapters-js.git"
},
"types": "./dist\\formatter.d.ts"
"types": "./dist\\formatter.d.ts",
"files": [
"dist"
]
}
Loading

0 comments on commit 7c4cabd

Please sign in to comment.