Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jacopo Scrinzi
16,668 PointsHow to test Flask-WTF forms
Hi there,
I'm writing my own Flask app and it's arrived the time to write my tests. I have no problem testing my models and my views but I have no clue where to start to test my Forms. What's the best way to do it? Do I have to test it though the views or I can test the forms on his own?
Thanks
2 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsI'd say forms are just view elements for users to input data, so I think testing the views and then checking the data ends up in the right place.
Jacopo Scrinzi
16,668 PointsThanks Ian for replying me, do you think I should chek in the view test the correct behaviour of the form error messages and so test every different possibility? or you think that is enough to test that the submission of the form works? thanks
Iain Simmons
Treehouse Moderator 32,305 PointsI think that's up to you, but maybe a good compromise is to test the different types of errors that you're handling? That might be invalid data, no connection to the database or wherever the data store is, or something just generally going wrong in the process of sending/saving the data.