Unittests in a custom app

Hi There,

I’ve built some unit tests for my custom DocTypes, inside a custom app. Some are associated with ERPNext DocTypes such as Customer, via a Link type field.

As per point 4 this guide, Customer test records are automatically being inserted when running MY tests:

I am running my tests as follows:
bench run-tests --app my_app

The test data in ERPNext is creating some side effects in my unit tests, even though they are in a separate app.

Is there a way to override this behaviour, so that test records outside of my app are not automatically inserted?


@dev_za try writing your tests in a more atomic way, maybe explicitly reset some parameters

Well, the issue is that because I have a Link field type in my doctype, the current test framework automatically inserts test_records.json from the referenced doctype package, when running tests on my doctype. So in other words, the current test framework has inherent side effects, as far as custom apps are concerned.

There doesn’t appear to be a way around this, unless I remove the link field type from my custom doctype in my custom module.