Full Clean Factories

Full Clean Factories

Researching the model instance factories available for Django and how well they create valid objects for our tests.

In this talk I present my research into various Django factories. Full write-up is available at http://jamescooke.info/django-factory-audit.html

B3c6f332ab773b78f4ebd72d56d7b6df?s=128

James Cooke

October 11, 2016
Tweet

Transcript

  1. Full Clean Factories James Cooke Licensed under the Creative Commons

    Attribution-ShareAlike 3.0 Unported License.
  2. Outline • Problem • Libraries • Grading factories • Factory

    features • Results
  3. Problem

  4. Factories • Django Fakery • Factory Boy • Factory Djoy

    • Hypothesis[django] • Mixer • Model Mommy
  5. Grading factories: Test • Two models: User and Item •

    Two factories: UserFactory and ItemFactory • Create 10 instances class Item(models.Model): name = models.CharField( max_length=1, unique=True)
  6. Grading factories: Grades • RED: Creates invalid instances • YELLOW:

    Raises exception • GREEN: Creates valid instances
  7. Factories Factory ItemFactory UserFactory Django Fakery RED YELLOW Factory Boy

    RED RED Factory Djoy YELLOW GREEN Hypothesis[django] RED RED Mixer GREEN GREEN Model Mommy YELLOW GREEN
  8. Final points • Factories are made of two parts •

    Hypothesis could win • Test code on GitHub: https://github.com/jamescooke/factory_audit/ • Full write-up tomorrow http://jamescooke.info/
  9. Thanks! • @jamesfublo • Ask questions • Let’s talk more

    about testing • Thanks for listening! Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.