autotest

command module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

autotest

golang-ci

Overview

Automated testing framework for api services, http, gRPC (may support in the future)

Features

  • No program development is required, only configuration files need to be written
  • You can specify dependencies between testcases
  • Testcases without dependencies can be executed concurrently and execute faster
  • Use xpath to extract variables for easy writing
  • supports importing variables from files and extracting variables from response

Install

1) use the compiled binary file

release

Obtain the bin file corresponding to the operating system and CPU architecture from the link above

2) compile by yourself
make build

or

go install github.com/vearne/autotest@latest

Usage

1) check configuration file
autotest test --config-file=${CONFIG_FILE}
2) execute automated tests
autotest run --config-file=${CONFIG_FILE} --env-file=${ENV_FILE}
3) extract the value corresponding to xpath
autotest extract --xpath=${XPATH} --json=${JSON}

Example

1) start a fake http api service
cd ./docker-compose
docker compose up -d
Add
curl -X POST 'http://localhost:8080/api/books' \
--header 'Content-Type: application/json' \
--data '{"title": "book3_title", "author": "book3_author"}'
Delete
curl -X DELETE 'http://localhost:8080/api/books/1'
Modify
curl -X PUT 'localhost:8080/api/books/3' \
--header 'Content-Type: application/json' \
--data '{"title": "book3_title", "author": "book3_author-2"}'
List
curl  'http://localhost:8080/api/books'
2) run automated test cases
autotest run -c=./config_files/autotest.yml -e=./config_files/.env.dev
3) extract the value corresponding to xpath

get the title of each book in the book list

autotest extract -x "//title" -j '[
 {
  "id": 2,
  "title": "Effective Go",
  "author": "The Go Authors"
 },
 {
  "id": 3,
  "title": "book3_title",
  "author": "book3_author-2"
 }
]'

TODO

  • 1) support utilizing the script language Lua to ascertain the conformity of HTTP responses with expectations.
  • 2) output report to file
  • 3) support automating tests for gRPC protocol-based API services.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
example
http_api Module
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL