Page MenuHomePhabricator

Convert TestCase from setUp() to setUpTestData()
Closed, ResolvedPublic

Description

TWL test suite is a bit slow. To try to speed it up, we will try to replace the setUp() function in TestCases with setUpTestData(). In a first iteration, we set the function up in the TWLight/tests.py file to see its performance.

Results of our initial test (see comments) were positive, so we should move forward and make this change in other tests where the effort required to do so is low.

Event Timeline

Before I replaced the setUp() method with setUpTestData(), I ran the tests in TWLight/tests.py and they ran for an average of 199.193s.

Test 1

Screen Shot 2021-05-05 at 16.47.26.png (366×1 px, 75 KB)

Test 2

Screen Shot 2021-05-05 at 16.52.50.png (364×1 px, 74 KB)

Test 3

Screen Shot 2021-05-05 at 16.56.27.png (372×1 px, 76 KB)

After I replaced the setUp() method with setUpTestData(), the tests now ran for an average of 184.893s.

Test 1

Screen Shot 2021-05-05 at 17.43.35.png (358×1 px, 75 KB)

Test 2

Screen Shot 2021-05-05 at 17.49.06.png (366×1 px, 74 KB)

Test 3

Screen Shot 2021-05-05 at 17.55.50.png (360×1 px, 74 KB)

In conclusion, tests run faster with this new implementation and we should go ahead and implement setUpTestData() on other tests.

Basically, this looks great, and we should make this change to all of our tests that can accept it without much effort.

Samwalton9 renamed this task from SPIKE: Convert TestCase from setUp() to setUpTestData() to Convert TestCase from setUp() to setUpTestData().May 6 2021, 3:29 PM
Samwalton9 triaged this task as Low priority.
Samwalton9 updated the task description. (Show Details)
Samwalton9 moved this task from Done to In Progress on the The-Wikipedia-Library (Kanban) board.
Samwalton9 added a subscriber: Samwalton9.

Rather than create a new task I just reframed this one for the rest of the work on this :)

Perfect, I'll tag my new work on this task as well.