Next generation test automation.


Keywords
test-agent, test-automation, test-framework
License
MIT
Install
pip install ngta==4.6.10

Documentation

中文 README


Guidehttps://ngta.readthedocs.io

Note:

  • from version 1.0, only support python>=3.5.2.
  • from version 2.0, don't compatible with unittest.
  • from version 4.0, only support python>=3.6.5.

Introduce:

NGTA's full name is Next Generation Test Automation, it designed with following keywords:

  • Business independent.
  • Cross platform.
  • Powerful parametrize for testcase.
  • Add testbench concept.
  • Add events mechanism.
  • Local mode:
    • powerful yml configuration with schema.
    • HTML report can be extended and customized.
    • Support running testcases with multi-process when testbench is not exclusive.
  • Agent mode:
    • Consume testcase from RabbitMQ with multi-processes.
    • Provide Http Restful interface.
    • Support Distributed.
    • Integrate with cavia platform.

Installation

  1. Install ngta:

    pip install ngta

  2. Generate work dir:

    python -m ngta init --dest-dir=${WORKDIR} --include-sample

Note: ${WORKDIR} indicate the target dir.

Why we need work dir:

  1. Test code also need version control, please use GIT.
  2. Good working structure is helpful for managing testcases.

The generated work dir:

${WORKDIR}                          root dir
|-- bin                             
    |-- agent.exe                   exe file for installing test agent as service in Windows.
    |-- agent.service               systemd service file for linux. 
    |-- agent.xml                   the config file for installing as service in Windows.
|-- cases                           tesetcase dir
    |-- sample1                     project or product dir1(GIT submodule1)
    |-- sample2                     project or product dir2(GIT submodule2)
|-- conf                            agent config files 
|-- lib                             internal libraries.
|-- logs                            userd for saving log, result and report.
|-- .ngta                           anchor file, also used to store configuration.

Node: For integrating with platform, create each project or product as git repository, and put it as git submodule into ${WORKDIR}/cases.


Sample:run test by yml config

  1. Open command-line, run following commands:

    cd ${WORKDIR}
    python -m ngta run --config=cases\sample\base\config.yml

  2. After running finished, we can found log and report in ${WORKDIR}\logs.
  3. In ${WORKDIR}\cases\sample\base\config.xml, it config how to load test in ${WORKDIR}\cases\sample\base\test_equal.py and inject the parameters.

Sample:run test by path

  1. Open command-line, run following commands:

    cd ${WORKDIR}
    python -m ngta run --locate=sample.base.test_equal

  2. After runing finished, we can found log and report in ${WORKDIR}\logs.

Note

  • --locate can be a package, module, class, method, py file or dir.
  • When specify --locate, it also support other arguments --tag, --include, --failfast, --repeat-number and etc.

Sample:run .py file

  1. Open command-line, run following commands:

    cd ${WORKDIR}\cases\sample\base
    python test_equal.py

  2. After runing finished, we can found report.html in ${WORKDIR}\cases\sample\base.

Different with unittest.TestCase:

Review ${WORKDIR}\cases\sample\base\test_equal.py:

# coding: utf-8
from ngta import TestCase, tag, test


class EqualTestCase(TestCase):
    @tag("regression")
    @test(u"Test {value1} equal with {value2}")
    def test_int(self, value1=1, value2=2):
        msg = "%s should equal with %s." % (value1, value2)
        self.assert_that(value1, msg).is_equal_to(value2)
  • @tag specify the tag regression
  • @test used to specify this is a testcase. Test method or function name start with test are also supported.
  • assert_that reference: assertpy

Report Sample:


More features: Guide