The ATS

In this part the Automatic Test Scripts (ATS) will be explained. It is assumed a general understanding about the pathways concept is acquired. Furthermore, a global understanding of testing in general is needed. A tester will typically work with ATS files.

Generally an ATS-file consists of a few parts, of which the ATS itself, a setup function and a teardown function. The constists ATS is the actual test. The setup function is an initialization of the test and the teardown function will shutdown the test. An ATS-file can consist of one or more ATS’s, setup and teardown functions. It is also possible to have a general setup and teardown function. Therefore, a test-set can have a structure like below. Note that the ATS specific setup and teardown functions are optional.

  • General setup function

    • Setup 1

    • ATS 1

    • Teardown 1

    • Setup n

    • ATS n

    • Teardown n

  • General teardown function

In the ATS-file used as an example a caculator is tested, which has different functionalities, such as a login and printscreen function and the general functions a calculator should have. The calculator that is tested is a simple calculator. Therefore, it can only substract, add, multiply and divide integers. The ATS-file used as an example has as a goal to test the calculation functions only.

The ATS Function

    logging.info("einde test")


def ATS_1(calc, vector, teardown):
    logging.info("start test 1")
    lastVal = 0
    for feed, expect in vector:
        som, num  = feed(0), feed(1)
        if som == "+":
            actual = calc.add(num)
        elif som == "-":
            actual = calc.sub(num)
        elif som == "/":
            actual = calc.div(num)
        elif som =="*":
            actual = calc.mul(num)
        else:
            print("foutje in het *.csv bestand")
            logging.error
        if actual != expect:
            logging.error #deze functie zou ook de som moeten printen die is uitgevoerd dus: (lastVal, som, num, '=', actual, '!=', expect
        else:
            logging.succes #geen idee of dit bestaat. Anders gewoon een print('test is OK!') of iets dergelijks. Zou wel mooi zijn als deze bestaat

In this function the external test data is used to perform calculations with the calculator. The result of this calculation is compared to the expected results in the test data. The function that has been defined needs three inputs: ‘calc’, ‘vector’ and ‘teardown’. These refer to the setup and teardown functions, with the help of fixtures.

Fixtures

Fixtures are a specific method where one can point to specific funtions. For example in the ATS function shown below, three parameters are included; calc, vector and teardown.

    logging.info("einde test")

The parameter ‘calc’ points to the function calc shown below. Using fixtures you are able to point to this whole function, instead of just one parameter. Therefore, calling upon the ATS_1 will first execute the ‘calc’ function and will return the calc value as a parameter to the ATS_1 function. The same principle holds for the teardown and vector function as well.

import logging

#onderstaande functie is een initializatie voor de test
@fixture.setup
def calc(inifile):
    gate = from_inifile(gate)       #weet dat dit niet klopt, maar weet niet hoe
    put = from_inifile(put)
    calc = tstObj(gate, put)        #kiest de rekenmachine
    calc.login                      #logt in op de rekenmachine

Vector function

From the test data file, which is a comma seperated file, the test data is imported. The test data has the following structure: +,2,,3. The data within this file is used to make calculations on the calculator which is tested. The first two characters are operations and the third character is the expected result. After a calculation the result of the calculator is compared to the expected result.

Caution

Ik zie geen reden meer om dit gescheiden te houden van de calc functie

Calc function

The Calc function is a fixture as well and it is an initilization for the test. In the ATS-file used as an example, the calculator that is tested is chosen. Furthermore, the Calculator will be made ready for the test itself. Note that for the test described in this document it makes sense to place the login function in the setup function.Would one like to test the login function explicity, it should be placed in the ATS.

import logging

#onderstaande functie is een initializatie voor de test
@fixture.setup
def calc(inifile):
    gate = from_inifile(gate)       #weet dat dit niet klopt, maar weet niet hoe
    put = from_inifile(put)
    calc = tstObj(gate, put)        #kiest de rekenmachine
    calc.login                      #logt in op de rekenmachine