-
Notifications
You must be signed in to change notification settings - Fork 82
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
Removed 4 unnecessary stubbings in RoundhouseActionTest.java #224
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package hudson.plugins.chucknorris; | ||
|
||
import static org.mockito.Mockito.mock; | ||
|
||
import hudson.model.Job; | ||
import hudson.model.Run; | ||
import junit.framework.TestCase; | ||
|
||
public class SecondRoundhouseActionTest extends TestCase { | ||
|
||
private RoundhouseAction action; | ||
|
||
private Run<?, ?> run; | ||
private RoundhouseAction lastBuildAction; | ||
|
||
@Override | ||
@SuppressWarnings("rawtypes") | ||
public void setUp() { | ||
action = new RoundhouseAction(Style.BAD_ASS, "Chuck Norris can divide by zero."); | ||
|
||
run = mock(Run.class); | ||
lastBuildAction = new RoundhouseAction(Style.ALERT, "Chuck Norris went out of an infinite loop."); | ||
final Job job = mock(Job.class); | ||
Run<?, ?> lastRun = mock(Run.class); | ||
} | ||
|
||
public void testAccessors() { | ||
assertEquals(Style.BAD_ASS, action.getStyle()); | ||
assertEquals("Chuck Norris can divide by zero.", action.getFact()); | ||
assertEquals("Chuck Norris", action.getDisplayName()); | ||
assertNull(action.getIconFileName()); | ||
assertEquals("chucknorris", action.getUrlName()); | ||
} | ||
|
||
public void testGetProjectActions() { | ||
assertNotNull(action.getProjectActions()); | ||
assertEquals(1, action.getProjectActions().size()); | ||
assertSame(action, action.getProjectActions().iterator().next()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||
package hudson.plugins.chucknorris; | ||||||
|
||||||
import static org.mockito.BDDMockito.given; | ||||||
import static org.mockito.Mockito.mock; | ||||||
|
||||||
import hudson.model.Job; | ||||||
import hudson.model.Result; | ||||||
import hudson.model.Run; | ||||||
import junit.framework.TestCase; | ||||||
|
||||||
public class ThirdRoundhouseActionTest extends TestCase { | ||||||
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. Please use JUnit 4 rather than JUnit 3 for the tests. JUnit 4 is more familiar to Jenkins developers and is widely used in Jenkins plugins. See the stackoverflow article for more details on why JUnit 4 annotations are better than JUnit 3 inheritance. Note that this suggestion won't compile if applied directly. Switching to JUnit 4 requires more than this single change.
Suggested change
|
||||||
|
||||||
private RoundhouseAction action; | ||||||
|
||||||
private Run<?, ?> run; | ||||||
private RoundhouseAction lastBuildAction; | ||||||
|
||||||
@Override | ||||||
@SuppressWarnings("rawtypes") | ||||||
public void setUp() { | ||||||
action = new RoundhouseAction(Style.BAD_ASS, "Chuck Norris can divide by zero."); | ||||||
|
||||||
run = mock(Run.class); | ||||||
given(run.getResult()).willReturn(Result.SUCCESS); | ||||||
|
||||||
lastBuildAction = new RoundhouseAction(Style.ALERT, "Chuck Norris went out of an infinite loop."); | ||||||
final Job job = mock(Job.class); | ||||||
Run<?, ?> lastRun = mock(Run.class); | ||||||
} | ||||||
|
||||||
public void testGetStyleFromRunResult() { | ||||||
action.onAttached(run); | ||||||
|
||||||
assertEquals(Style.THUMB_UP, action.getStyle()); | ||||||
} | ||||||
} |
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.
Please use JUnit 4 rather than JUnit 3 for the tests. JUnit 4 is more familiar to Jenkins developers and is widely used in Jenkins plugins. See the stackoverflow article for more details on why JUnit 4 annotations are better than JUnit 3 inheritance.
Note that this suggestion won't compile if you apply it directly.