Improved feed reader testing
This commit is contained in:
parent
86b35874bf
commit
8e37c3912a
1 changed files with 8 additions and 4 deletions
|
@ -59,8 +59,13 @@ class FeedReaderTest {
|
||||||
|
|
||||||
messages = readFeed("https://lorem-rss.herokuapp.com/feed?length=84", 42)
|
messages = readFeed("https://lorem-rss.herokuapp.com/feed?length=84", 42)
|
||||||
assertThat(messages, "messages").size().isEqualTo(84)
|
assertThat(messages, "messages").size().isEqualTo(84)
|
||||||
assertThat(messages[messages.size - 2], "messages.size - 2").prop(Message::msg).startsWith("Lorem ipsum")
|
messages.forEachIndexed { i, m ->
|
||||||
assertThat(messages.last(), "messages.last").prop(Message::msg).contains("http://example.com/test/")
|
if (i % 2 == 0) {
|
||||||
|
assertThat(m, "messages($i)").prop(Message::msg).startsWith("Lorem ipsum")
|
||||||
|
} else {
|
||||||
|
assertThat(m, "messages($i)").prop(Message::msg).contains("http://example.com/test/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assertFailure { readFeed("blah") }.isInstanceOf(MalformedURLException::class.java)
|
assertFailure { readFeed("blah") }.isInstanceOf(MalformedURLException::class.java)
|
||||||
|
|
||||||
|
@ -68,7 +73,6 @@ class FeedReaderTest {
|
||||||
|
|
||||||
assertFailure { readFeed("https://www.thauvin.net/foo") }.isInstanceOf(IOException::class.java)
|
assertFailure { readFeed("https://www.thauvin.net/foo") }.isInstanceOf(IOException::class.java)
|
||||||
|
|
||||||
assertFailure { readFeed("https://www.examplesfoo.com/") }
|
assertFailure { readFeed("https://www.examplesfoo.com/") }.isInstanceOf(UnknownHostException::class.java)
|
||||||
.isInstanceOf(UnknownHostException::class.java)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue