I wish to write python test case for my feature. I am looking for basic initial environment steps.
Ex. I looked at existing test cases they use test data ex Test Customer so (a)how to have this test data attached when i run the test. (b) are there any pre requisite to run test case (c) any useful links for writing test cases.
Have a look at the test_records.json file in the doctype folder for inspiration. The test runner uses it to create records. You can also manually create using frappe.get_doc. Another option is to make use of the record that have already been created.
@tundebabzy thanks…When i run existing test case with test customer and test product…Such data is not in my site…So test case fails…My question is how to load test data?
“Another option is to make use of the record that have already been created.”— by default this data is not present in db
On running bench run-tests all test data gets created on default site.
The confusion happens as automated link mentions “Tests must run on a site that starts with test_. This is to prevent accidental loss of data” → which is not mandatory.
Thanks @tundebabzy and @clarkej for your time and help.