oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
425 stars 81 forks source link

Test infrastructure refactor #107

Closed telenieko closed 5 years ago

telenieko commented 5 years ago

This PR proposes a new test insfrastructure based on pytest. Currently it does more profound testing of what was already tested, though a lot is still to be done.

The test suite will generate a Coverage report and a pytest report. The pytest report includes screenshots. See samples here:

Current coverage with it is up to 57% from 39% previously. What follows is part of the commit message of 79f84f7.

The test system now uses pytest with some useful plugins as I believe pytest to be considerably easier to use than standard django test suite. To run tests:

pytest

We also enable Selenium for client side testing and to generate screenshots. To test without selenium:

pytest -m 'not selenium'

Pre-existing tests have been migrated and some other tests have been added bringing the current coverage to 57% up from 39%. Note that previous testing was prrety much a call to crud_for_app, the current tests actually test for some of the functionality, though a lot is yet to be written.

Also, what was now 'testapp' is now 'test_project' and 'test_project.testapp' to allow a) to use pytest-django and b) to make it easier to further extend the testapp/test_project for more testing.

Last but not least, you can't use "python setup.py test" but have to go with "pytest". That was to avoid another dependency on pytest-runner. It's something to keep working.

telenieko commented 5 years ago

I added 442c892 which add some tips about the testsuite into CONTRIBUTING.rst

oscarmlage commented 5 years ago

@telenieko merged! thanks for the amazing work here!! I do agree on pytest decision, for me it's much better than Django unittest and it has many really interesting plugins.