Skip to content

Commit a8ca586

Browse files
committed
switched from AssertException to @test(expected = IllegalArgumentException.class)
1 parent b1e1727 commit a8ca586

File tree

3 files changed

+7
-183
lines changed

3 files changed

+7
-183
lines changed

src/test/java/pl/project13/jgit/DescribeCommandOptionsTest.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,28 @@
2222
import org.mockito.Matchers;
2323
import pl.project13.maven.git.GitCommitIdMojo;
2424
import pl.project13.maven.git.GitDescribeConfig;
25-
import pl.project13.test.utils.AssertException;
2625

2726
import static org.mockito.Mockito.*;
2827

2928
public class DescribeCommandOptionsTest {
3029

3130

32-
@Test
31+
@Test(expected = IllegalArgumentException.class)
3332
public void abbrev_shouldVerifyLengthContract_failOn41() throws Exception {
3433
// given
3534
final Repository repo = mock(Repository.class);
3635
final int length = 41;
3736

38-
// when
39-
AssertException.CodeBlock block = new AssertException.CodeBlock() {
40-
@Override
41-
public void run() throws Exception {
42-
DescribeCommand.on(repo).abbrev(length);
43-
}
44-
};
45-
46-
// then
47-
AssertException.thrown(IllegalArgumentException.class, block);
37+
DescribeCommand.on(repo).abbrev(length);
4838
}
4939

50-
@Test
40+
@Test(expected = IllegalArgumentException.class)
5141
public void abbrev_shouldVerifyLengthContract_failOnMinus12() throws Exception {
5242
// given
5343
final Repository repo = mock(Repository.class);
5444
final int length = -12;
5545

56-
// when
57-
AssertException.CodeBlock block = new AssertException.CodeBlock() {
58-
@Override
59-
public void run() {
60-
DescribeCommand.on(repo).abbrev(length);
61-
}
62-
};
63-
64-
// then
65-
AssertException.thrown(IllegalArgumentException.class, block);
46+
DescribeCommand.on(repo).abbrev(length);
6647
}
6748

6849
@Test
@@ -88,4 +69,4 @@ public void apply_shouldDelegateToAllOptions() throws Exception {
8869
verify(spiedCommand).tags(Matchers.eq(true));
8970
verify(spiedCommand).forceLongFormat(Matchers.eq(true));
9071
}
91-
}
72+
}

src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.eclipse.jgit.api.ResetCommand;
3030
import org.junit.Test;
3131
import org.junit.runner.RunWith;
32-
import pl.project13.test.utils.AssertException;
3332

3433
import java.io.File;
3534
import java.nio.charset.Charset;
@@ -154,7 +153,7 @@ public void shouldUseChildProjectRepoIfInvokedFromChild(boolean useNativeGit) th
154153
assertGitPropertiesPresentInProject(targetProject.getProperties());
155154
}
156155

157-
@Test
156+
@Test(expected = MojoExecutionException.class)
158157
@Parameters(method = "useNativeGit")
159158
public void shouldFailWithExceptionWhenNoGitRepoFound(boolean useNativeGit) throws Exception {
160159
// given
@@ -168,16 +167,7 @@ public void shouldFailWithExceptionWhenNoGitRepoFound(boolean useNativeGit) thro
168167
alterMojoSettings("skipPoms", false);
169168
alterMojoSettings("useNativeGit", useNativeGit);
170169

171-
// when
172-
AssertException.CodeBlock block = new AssertException.CodeBlock() {
173-
@Override
174-
public void run() throws Exception {
175-
mojo.execute();
176-
}
177-
};
178-
179-
// then
180-
AssertException.thrown(MojoExecutionException.class, block);
170+
mojo.execute();
181171
}
182172

183173
@Test

src/test/java/pl/project13/test/utils/AssertException.java

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)