Skip to content

Commit

Permalink
Improve NextLabelCause Test Coverage (#370)
Browse files Browse the repository at this point in the history
* NextLabelCauseTest-added

Signed-off-by: shinigami-777 <[email protected]>

* Use equalsverifier with NextLabelCause

Provides a deeper test of the equals contract and the hashCode
contract.

* moved-contents-of-setup

Signed-off-by: shinigami-777 <[email protected]>

* removed-comment

* comment-reverted-back

* Remove inaccurate comment

---------

Signed-off-by: shinigami-777 <[email protected]>
Co-authored-by: Mark Waite <[email protected]>
  • Loading branch information
shinigami-777 and MarkEWaite authored Dec 23, 2024
1 parent 287c3b8 commit 02049f2
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.jvnet.jenkins.plugins.nodelabelparameter;

import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class NextLabelCauseTest {

@Rule
public JenkinsRule j = new JenkinsRule();

@Test
public void testGetShortDescription() throws Exception {
FreeStyleProject project = j.createFreeStyleProject("projectB");
FreeStyleBuild build = j.buildAndAssertSuccess(project);
NextLabelCause cause = new NextLabelCause("dummylabel", build);
String description = cause.getShortDescription();
Assert.assertEquals(description, "A build with label/node [dummylabel] was requested");
}

@Test
public void testEqualsContract() {
EqualsVerifier.forClass(LabelParameterValue.class)
.usingGetClass()
.suppress(Warning.NONFINAL_FIELDS)
.withIgnoredFields("description", "nextLabels")
.verify();
}
}

0 comments on commit 02049f2

Please sign in to comment.