Tuesday, September 3, 2019

Re: Making tests fast



On Wed, Sep 4, 2019 at 4:52 AM Dan Davis <dansmood@gmail.com> wrote:
I'm wondering how to make my tests fast while also having a lot of data defined in the models.  
This project is already using sqlite3 and the tests are single-threaded.


Django support parallel, you can use multi process to save time.
  --parallel [N]        Run tests using up to N parallel processes.

 And also I don't recommend to use sqlite, I think it's not as fast as PostgreSQL, you also can use memory database for PostgreSQL as well.

Only use the minimal required fixtures for each test, because setup and delete the data are slow. Also use TestCase instead of TranscationTestCase if you can, via https://adamj.eu/tech/2019/07/15/djangos-test-case-classes-and-a-three-times-speed-up/ .
 
My ideas are:
I am loathe to use modelmommy and/or factoryboy because they are simply a bit harder to use.   I'd rather use dump data/load data with :memory database.

   

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b22204f4-85db-4eb9-9a53-adca0dea269c%40googlegroups.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABexzmiyOPwZ8X3-5WySF-Rocr-RZ_hCMQm0udijLu-10o7Dew%40mail.gmail.com.

No comments:

Post a Comment