YaST2 modules testsuite -- Testing


Testing

Presume you have already prepared your testsuite acording to preparation chapter.

You should now have testsuite/ directory with tests/ subdir and Makefile, Makefile.am and Makefile.in.

Also presume you have already some tests created. If not, take a look at creation chapter.

For instance, there is a Test1.ycp test case in the testsuite/tests/ directory.

Running tests

Change dir to the testsuite directory and run
    bash$ make check
This command produce a lot of output and some files. During a first run, it says "test failed", but it doesn't matter as we just started to create the testsuite and it's now a work in progress. Interesting files are those "tmp.*". There is a normal (tmp.out.*) and error (tmp.err.*) output of the real check.

After creation of Test1.ycp and make check, there should be a tmp.out.Test1 and tmp.err.Test1 files. The error file should be empty (no errors) and in the output file there is a test output.

Diffing output

Take a look at the output files, if they contains the right output (no errors, right results).

Often large YCP lists or maps are involved, all on a single line, and an ordinary diff does not help. Use wdiff from wdiff.rpm to diff by words:

    bash$ wdiff -la tmp.out.Test1 tests/Test1.out

Updating output

If the output files are OK, copy them to tests/Test1.out (tmp.out.Test1) and tests/Test1.err (tmp.err.Test1).

    bash$ cp tmp.out.Test1 tests/Test1.out
    bash$ touch tests/Test1.err

Now, you have a (one) testsuite ready. The output files will be used during the next check run for comparison with real output to decide if the test passed.

Note: as you may see, the test is based on a comparison of a given and a real outputs of the test run

Finish

Now, the testsuite should be ready. Run the check once more to ensure everything went OK.
    bash$ make check