Wednesday, November 4, 2015

Best practices for writing functional tests to exercise forms?

Beginning a new project, I'd like to include functional testing in
addition to my unit tests. What are recommended best practices for
exercising form-classes? I was hoping to do something like

c = django.test.Client()
results = c.get(page_url)
frm = SomeForm()
# pseudo-code for desired functional testing follows
self.assertFormIn(frm, results) # check the form is used
frm["name"] = "Pat Smith"
frm["email"] = "psmith@example.com"
results = c.post(page_url, frm) # submit the filled-out form
# check results for error messages and/or success here

Is there some piece of Django that I've missed that would facilitate
higher-level tests like this?

Thanks,

-tkc



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20151104103632.38e014a4%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment