Modify

Opened 8 years ago

Closed 8 years ago

#12949 closed enhancement (fixed)

[Patch] Use test rule instead of JOSMFixture to speed up tests.

Reported by: michael2402 Owned by: team
Priority: major Milestone: 16.06
Component: Unit tests Version:
Keywords: gsoc-core performance Cc: Don-vip, bastiK, stoecker

Description

During #12937, we noticed a problem with the tests being slow.

A single test takes more than 1s to run due to the slow initialization of the JSOMFixture class.

This patches imporves the situation: We use a TestRule added in JUnit 4.9. This allows us to add custom cleanup code before / after each test case. The code is fine graned so that you can e.g. only instanciate preferences. Preferences use the default preferences and do not write back to disk on default. A basic OSM API is faked (corrently only for image blacklist) - in the old version the capabilies were requested for every test.

I designed the code to be short and make it easy to implement more features. We might improve the performance of some implementations (preferences, platform, ...) in the future but they are already much faster than the normal JOSM fixture.

Using a faked OSM API we can make unit tests not depend on the OSM server - this should be done in integration tests.

The rule supports forkmode="once"

==AddImageryLayerActionTest==
Old:
JOSM src code coverage: 13.5%
Run time using the fork per test policy: 8.369s
Run time using the fork once policy: 1.698s

New:
JOSM src code coverage: 2.6%
Run time using the fork per test policy: 2.265s (most of which are HTTP requests for the TMS/... layers)
Run time using the fork once policy: 0.650s

==SearchCompilerTest==
Old:
JOSM src code coverage: 2.1%
Run time using the fork per test policy: 3.173s
Run time using the fork once policy: 1.122s

New:
JOSM src code coverage: 1.2%
Run time using the fork per test policy: 1.229s
Run time using the fork once policy: 1.084s

Attachments (1)

patch-tests-use-rules.patch (20.0 KB ) - added by michael2402 8 years ago.

Download all attachments as: .zip

Change History (3)

by michael2402, 8 years ago

Attachment: patch-tests-use-rules.patch added

comment:1 by Don-vip, 8 years ago

Component: CoreUnit tests
Keywords: performance added
Priority: normalmajor

comment:2 by Don-vip, 8 years ago

Resolution: fixed
Status: newclosed

In 10373/josm:

fix #12949 - Use test rule instead of JOSMFixture to speed up tests (patch by michael2402) - gsoc-core

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.