Opened 2 years ago

Last modified 2 years ago

#34184 closed New feature

Improve tutorial by mentioning User Interaction testing like django-webtest — at Version 1

Reported by: Kees Hink Owned by: nobody
Component: Documentation Version: 4.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Kees Hink)

Maybe the tutorial chapter about testing (https://docs.djangoproject.com/en/4.1/intro/tutorial05/) could be improved a bit by adding a reference to User Interaction testing, as provided for example by https://github.com/django-webtest/django-webtest.

One example where Django's TestCase is not super well suited is a form submit. Yes, it's possible to craft a POST request, but it's not guaranteed that a form will actually submit the same data.

Webtest allows user-like interaction by clicking items in a page, filling out a form and submitting it, and following redirects.

In my opinion it's very valuable for comprehensive testing, and i think our tutorial would improve if we mention it.

One could argue that Selenium (which is referenced on the page under "Further testing") could be used to achieve this, but that is more work to set up, and slower. (I do think Selenium / Playwright) has its place in other scenarios.) If it's about testing a form submit, no JavaScript, then webtest is more suitable, and very similar to Django's TestCase.

If this is a good idea, i'm happy to make a proposal PR. (Edit: I've made a suggestion at https://github.com/django/django/pull/16330)

Change History (1)

comment:1 by Kees Hink, 2 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top