Page MenuHomeWildfire Games

Add test for Upgrade Component
ClosedPublic

Authored by s0600204 on May 19 2017, 6:25 PM.

Details

Reviewers
fatherbushido
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP19686: Add a test for the Upgrade Component, focusing on tech modifications.
Summary

This is the same test file that can be found in P18, used to help test aspects of D92 and D146.

This test tests both the Upgrade simulation component and the function in globalscripts that deals with it, taking into account tech modifications where applicable.

Test Plan

Run the test. It should pass without error.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

s0600204 created this revision.May 19 2017, 6:25 PM
Vulcan added a subscriber: Vulcan.May 19 2017, 7:13 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1252/ for more details.

fatherbushido edited edge metadata.May 22 2017, 1:03 PM

(That test indeed doesn't fit in any other file. I don't know what's our policy about that.
Even if I tend to prefer to test things individually, that one makes sense as it shows a bug we encountered.)

Some quick inline remarks.

Finally, after my inline comments, you can just makes that unit tests for ugrade component alone.
You can even mock TechnologyManager (mock its ApplyModification functions) and add that mock at L128.

binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
28 ↗(On Diff #2025)

imo mock that

29 ↗(On Diff #2025)

imo mock that

80 ↗(On Diff #2025)

so just mock here

85 ↗(On Diff #2025)

mock that too

95 ↗(On Diff #2025)

all that part would be away

s0600204 updated this revision to Diff 2154.May 23 2017, 7:03 PM
s0600204 marked 5 inline comments as done.

Mocked the Player and PlayerManager components.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1329/ for more details.

Build is green

Executing section Default...
Executing section Source...
Executing section JS...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/22/ for more details.

s0600204 updated this revision to Diff 2160.May 23 2017, 11:06 PM

Gently mock the TechnologyManager component.

Build is green

Executing section Default...
Executing section Source...
Executing section JS...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/25/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1333/ for more details.

I don't want to be annoying but perhaps you can look the comments I just add.
(You can perhaps also rename the file in test_Upgrade.js (even if we don't test all that component) - no clue about that. I will agree with your choice.)

Also nothing important but you can remove the () for single argument in arrow function if you want.

binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
52 ↗(On Diff #2160)

I like!

76 ↗(On Diff #2160)

so you could nuke all that

85 ↗(On Diff #2160)

And perhaps we could so get rid of that.

154 ↗(On Diff #2160)

I would just add a mock for the "ApplyModifications" method here (so no need to boolean...)
And perhaps I am wrong but we don't need anymore "ApplyModificationsTemplate" in that component.

s0600204 updated this revision to Diff 2174.May 24 2017, 5:50 PM
s0600204 marked an inline comment as done.

Remove unnecessary code.

Also add comments mentioning where each of the Mocked components' functions are used.

Hopefully the additional line comments help make it easier to tell what's used where.

[...] you can remove the () for single argument in arrow function if you want.

Forgot to do that this time round. I'll do it for the next diff.

Build is green

Executing section Default...
Executing section Source...
Executing section JS...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/37/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1346/ for more details.

Hopefully the additional line comments help make it easier to tell what's used where.

[...] you can remove the () for single argument in arrow function if you want.

Forgot to do that this time round. I'll do it for the next diff.

Last comments, nothing really mandatory.

Ah yes I read to quickly to see the whole test, indeed we need the template mod. Now test is imo more isolated and test that whole past issue.
Don't know about the name of the file.
Some could say there are two many comments, but it's a matter of style and I m fine with that ;-)
Remains that partenthesis that you can remove, that newline and perhaps the missing spaces in objects in the TS_ASSERT things.

binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
112 ↗(On Diff #2174)

ok you did the choice to do that and then call cmpPlayer.GetPlayerID() on what follow
I would just use that number (1) or a playerID variable (used also at L94) instead but that's ok.

113 ↗(On Diff #2174)

no need I think

125 ↗(On Diff #2174)

perhaps extra newline

s0600204 updated this revision to Diff 2204.May 26 2017, 12:39 AM
s0600204 marked 3 inline comments as done.

Code style tweaks.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1362/ for more details.

Build is green

Executing section Default...
Executing section Source...
Executing section JS...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/49/ for more details.

This revision is now accepted and ready to land.May 26 2017, 8:58 AM

Don't forget
svn propset svn:eol-style native binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
before commiting

This revision was automatically updated to reflect the committed changes.