I’m coming from this thread - At times, the custom field is not getting created through fixtures. Why would it happen? - #4 by kirthi
The fields are created, but they are deleted when I run tests. I traced the issue to this before_tests hook.
def before_tests():
frappe.db.sql(“delete from tabCustom Field
”)
frappe.db.sql(“delete from tabEvent
”)
frappe.db.commit()
frappe.clear_cache()
Here, all the custom fields are deleted prior to test execution. This means that all our custom fields are deleted, and the tests fail. (For Eg. - I have a custom field added to BOM, and have a hook to check that field on submit of BOM. When I run tests, the custom fields are deleted, and the on_submit event calls my custom function to check for the custom field, and test execution fails since the field is already deleted.
Since I’m very new to run-tests, I dont know the purpose behind removing all custom fields.
Can the experts in running tests in ERPNext , help me out. My basic qn is -
- If all custom fields are removed before tests, how do I test my custom fields?
How do I go about resolving this issue, and run tests successfully that includes my custom fields also.