Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contract market tests #2294

Merged

Conversation

sixlettervariables
Copy link
Contributor

This adds some basic contract market tests to avoid situations like #2283 in the future.

In order to accomplish this I needed to do four things first:

  1. Add Systems::setInstance to let me mock static usages of Systems.getInstance()
  2. Add RandomFactionGenerator::setInstance to let me mock static usages of RandomFactionGenerator::getInstance()
  3. Move static methods from Faction into Factions and make them instance methods
  4. Add Factions::getInstance(), and Factions::setInstance to let me mock the previously static methods

That commit is acb530c

The subsequent commits all make use of that work to add basic tests for the ContractMarket.

@codecov
Copy link

codecov bot commented Dec 16, 2020

Codecov Report

Merging #2294 (44c375d) into master (a18bf31) will increase coverage by 1.92%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2294      +/-   ##
============================================
+ Coverage      8.35%   10.28%   +1.92%     
- Complexity     2601     3408     +807     
============================================
  Files           672      674       +2     
  Lines         95008    94902     -106     
  Branches      15965    15933      -32     
============================================
+ Hits           7934     9756    +1822     
+ Misses        86008    83776    -2232     
- Partials       1066     1370     +304     
Impacted Files Coverage Δ Complexity Δ
MekHQ/src/mekhq/service/MassRepairOption.java 13.33% <0.00%> (-1.74%) 2.00% <0.00%> (-1.00%)
MekHQ/src/mekhq/campaign/Quartermaster.java 90.98% <0.00%> (-1.23%) 84.00% <0.00%> (+4.00%) ⬇️
...hq/campaign/parts/equipment/LargeCraftAmmoBin.java 55.06% <0.00%> (-0.71%) 37.00% <0.00%> (ø%)
MekHQ/src/mekhq/Version.java 15.09% <0.00%> (-0.60%) 1.00% <0.00%> (ø%)
MekHQ/src/mekhq/campaign/personnel/Person.java 9.75% <0.00%> (-0.02%) 61.00% <0.00%> (ø%)
MekHQ/src/mekhq/gui/CampaignGUI.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
MekHQ/src/mekhq/gui/CommandCenterTab.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
MekHQ/src/mekhq/campaign/parts/MekGyro.java 25.92% <0.00%> (ø) 13.00% <0.00%> (ø%)
MekHQ/src/mekhq/campaign/parts/PodSpace.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
MekHQ/src/mekhq/campaign/work/IPartWork.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
... and 113 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a18bf31...30aeaf1. Read the comment docs.

@sixlettervariables
Copy link
Contributor Author

Looks like by removing the incidental thread load of Systems I decreased coverage in tests that never really used it anyways.

I'll add a test to load the data and check it.

@sixlettervariables sixlettervariables added the Tests Issues or Pull Requests related to the project tests label Dec 28, 2020
@sixlettervariables sixlettervariables merged commit 05bda11 into MegaMek:master Dec 30, 2020
@sixlettervariables sixlettervariables deleted the add-contract-market-tests branch December 30, 2020 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tests Issues or Pull Requests related to the project tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants