This repository was archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Do not use color for unchanged coverage #777 #789
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2b01fe1
Do not use color for unchanged coverage #777
Amanjain4269 c81ac95
Updated the code per maintainer's feedback.
Amanjain4269 023f33a
Updated the TestCases as per the reviews.
Amanjain4269 8781e08
Made the changes
Amanjain4269 c0a2b1c
Made final changes
Amanjain4269 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import java.util.List; | ||
| import java.util.TreeMap; | ||
| import java.util.Optional; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.commons.lang3.math.Fraction; | ||
|
|
@@ -30,6 +31,24 @@ | |
| */ | ||
| @DefaultLocale("en") | ||
| class CoverageBuildActionTest { | ||
| private CoverageBuildAction createCoverageBuildActionWithDelta(final Metric metric, final Optional<Fraction> delta) { | ||
| Node module = new ModuleNode("module"); | ||
|
|
||
| var coverageBuilder = new CoverageBuilder(); | ||
| var percent = coverageBuilder.setMetric(metric).setCovered(1).setMissed(1).build(); | ||
|
|
||
| module.addValue(percent); | ||
|
|
||
| var deltas = new TreeMap<Metric, Fraction>(); | ||
| delta.ifPresent(d -> deltas.put(metric, d)); | ||
|
|
||
| var coverages = List.of(percent); | ||
|
|
||
| return spy(new CoverageBuildAction(mock(FreeStyleBuild.class), CoverageRecorder.DEFAULT_ID, | ||
| StringUtils.EMPTY, StringUtils.EMPTY, module, new QualityGateResult(), | ||
| createLog(), "-", deltas, coverages, deltas, coverages, deltas, coverages, false)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldNotLoadResultIfCoverageValuesArePersistedInAction() { | ||
| Node module = new ModuleNode("module"); | ||
|
|
@@ -88,4 +107,28 @@ void shouldCreateViewModel() { | |
| assertThat(action.getTarget()).extracting(CoverageViewModel::getNode).isSameAs(root); | ||
| assertThat(action.getTarget()).extracting(CoverageViewModel::getOwner).isSameAs(action.getOwner()); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnPositiveTrendForLineMetric() { | ||
| CoverageBuildAction action = createCoverageBuildActionWithDelta(Metric.LINE, Optional.of(Fraction.getFraction(1, 1000))); | ||
| assertThat(action.getTrend(Baseline.PROJECT, Metric.LINE)).isPositive(); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnNegativeTrendForLineMetric() { | ||
| CoverageBuildAction action = createCoverageBuildActionWithDelta(Metric.LINE, Optional.of(Fraction.getFraction(-1, 1000))); | ||
| assertThat(action.getTrend(Baseline.PROJECT, Metric.LINE)).isNegative(); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnZeroForDeltaWithinBoundaries() { | ||
| CoverageBuildAction action = createCoverageBuildActionWithDelta(Metric.LINE, Optional.of(Fraction.getFraction(9, 10_000))); | ||
| assertThat(action.getTrend(Baseline.PROJECT, Metric.LINE)).isZero(); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnZeroWhenDeltaIsNotPresentForGivenMetric() { | ||
| CoverageBuildAction action = createCoverageBuildActionWithDelta(Metric.LINE, Optional.empty()); | ||
| assertThat(action.getTrend(Baseline.PROJECT, Metric.LINE)).isZero(); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests look good now! Just a couple of analysis warnings remaining... |
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a not required import in line 21