Basics of Writing Automated Tests in Arjuna¶
Tests are Test Functions¶
Writing a basic test in Arjuna is very easy. Following is a simple test skeleton:
Basic Usage of @test Decorator¶
from arjuna import *
@test
def check_test_name(request):
pass
Create a test module in <Project Root Directory>/test/pkg. The module name should start with the prefix check_
In the python test module file, import all names from Arjuna: from arjuna import *. Ofcourse, as you become more aware of Arjuna’s TPI (tester programming interface), you can do selective imports using Python.
Create a test. In Arjuna, a test is a function marked with @test decorator. It must start with the prefix check_. It should take one mandatory argument: request.
The contents of the test function depend on the test that you want to write.
Running a Specific Test Function¶
pytest -p arjuna --project path/to-proj_name --itest check_test_name
- Note:
pytest determines root directory in various ways. If you are facing difficulties with test discovery, try the following: * If your IDE provisions it, set the current working directory to test project root directory. * Cd into the project root * Add these to command line: –project . -c pytest.ini
To learn more about other options for controlling which tests are run, refer Controlling Test Selection