Skip to content

Commit 6623047

Browse files
committed
refactor(JsoupSiteParserTest): replace ExpectedException by assertThat() for handling exceptions.
1 parent 1bf6305 commit 6623047

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/test/java/ru/mystamps/web/feature/series/importing/extractor/JsoupSiteParserTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
import org.jsoup.nodes.Document;
2323
import org.jsoup.nodes.Element;
2424
import org.junit.Before;
25-
import org.junit.Rule;
2625
import org.junit.Test;
27-
import org.junit.rules.ExpectedException;
2826
import ru.mystamps.web.tests.Random;
2927
import java.util.Locale;
3028

@@ -34,9 +32,6 @@
3432

3533
public class JsoupSiteParserTest implements WithAssertions {
3634

37-
@Rule
38-
public ExpectedException thrown = ExpectedException.none();
39-
4035
private JsoupSiteParser parser;
4136

4237
@Before
@@ -50,10 +45,15 @@ public void init() {
5045

5146
@Test
5247
public void parseShouldRequireNonBlankPageContent() {
53-
thrown.expect(IllegalArgumentException.class);
54-
thrown.expectMessage("Page content must be non-blank");
55-
56-
parser.parse(nullOrBlank());
48+
// given
49+
// when
50+
Throwable thrown = catchThrowable(() -> {
51+
parser.parse(nullOrBlank());
52+
});
53+
// then
54+
assertThat(thrown)
55+
.isInstanceOf(IllegalArgumentException.class)
56+
.hasMessage("Page content must be non-blank");
5757
}
5858

5959
@Test

0 commit comments

Comments
 (0)