Added test groups

This commit is contained in:
Erik C. Thauvin 2022-09-17 10:48:30 -07:00
parent 893d554136
commit 646682e2a9
26 changed files with 44 additions and 45 deletions

View file

@ -131,7 +131,6 @@ compileJava {
options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)

View file

@ -38,7 +38,7 @@ import net.thauvin.erik.mobibot.commands.Info.Companion.toUptime
import org.testng.annotations.Test
class InfoTest {
@Test
@Test(groups = ["commands"])
fun testToUptime() {
assertThat(547800300076L.toUptime(), "full").isEqualTo("17 years 2 months 2 weeks 1 day 6 hours 45 minutes")
assertThat(24300000L.toUptime(), "hours minutes").isEqualTo("6 hours 45 minutes")

View file

@ -41,7 +41,7 @@ import assertk.assertions.size
import org.testng.annotations.Test
class RecapTest {
@Test
@Test(groups = ["commands"])
fun storeRecapTest() {
for (i in 1..20) {
Recap.storeRecap("sender$i", "test $i", false)

View file

@ -44,19 +44,19 @@ import org.testng.annotations.Test
class LinksMgrTest {
private val linksMgr = LinksMgr()
@Test
@Test(groups = ["commands", "links"])
fun fetchTitle() {
assertThat(linksMgr.fetchTitle("https://erik.thauvin.net/"), "Erik").contains("Erik's Weblog")
assertThat(linksMgr.fetchTitle("https://www.google.com/foo"), "Foo").isEqualTo(Constants.NO_TITLE)
}
@Test
@Test(groups = ["commands", "links"])
fun testMatches() {
assertThat(linksMgr.matches("https://www.example.com/"), "https").isTrue()
assertThat(linksMgr.matches("HTTP://erik.thauvin.net/blog/ Erik's Weblog"), "HTTP").isTrue()
}
@Test
@Test(groups = ["commands", "links"])
fun matchTagKeywordsTest() {
linksMgr.setProperty(LinksMgr.KEYWORDS_PROP, "key1 key2,key3")
val tags = mutableListOf<String>()

View file

@ -40,7 +40,7 @@ import net.thauvin.erik.mobibot.entries.EntryLink
import org.testng.annotations.Test
class ViewTest {
@Test
@Test(groups = ["commands", "links"])
fun testParseArgs() {
val view = View()

View file

@ -59,7 +59,7 @@ class SeenTest {
tmpFile.deleteIfExists()
}
@Test(priority = 1)
@Test(priority = 1, groups = ["commands"])
fun loadTest() {
seen.clear()
assertThat(seen.seenNicks.isEmpty(), "nicknames map is not empty").isTrue()
@ -67,7 +67,7 @@ class SeenTest {
assertThat(seen.seenNicks.containsKey(nick), "nick is missing").isTrue()
}
@Test
@Test(groups = ["commands"])
fun addTest() {
val last = seen.seenNicks[nick]?.lastSeen
seen.add(nick.lowercase())
@ -76,7 +76,7 @@ class SeenTest {
assertThat(seen.seenNicks[nick]?.nick, "nick is not lowercase").isEqualTo(nick.lowercase())
}
@Test(priority = 10)
@Test(priority = 10, groups = ["commands"])
fun clearTest() {
seen.clear()
seen.save()

View file

@ -50,7 +50,7 @@ class TellMessageTest {
return Duration.between(date, LocalDateTime.now()).toMinutes() < 1
}
@Test
@Test(groups = ["commands", "tell"])
fun testTellMessage() {
val message = "Test message."
val recipient = "recipient"

View file

@ -68,7 +68,7 @@ class TellMessagesMgrTest {
testFile.deleteIfExists()
}
@Test
@Test(groups = ["commands", "tell"])
fun cleanTest() {
testMessages.add(TellMessage("sender", "recipient", "message").apply {
queued = LocalDateTime.now().minusDays(maxDays)
@ -79,7 +79,7 @@ class TellMessagesMgrTest {
assertThat(testMessages.size, "size-- after clean").isEqualTo(size - 1)
}
@Test
@Test(groups = ["commands", "tell"])
fun loadTest() {
val messages = TellMessagesMgr.load(testFile.toAbsolutePath().toString())
for (i in messages.indices) {

View file

@ -59,17 +59,17 @@ class EntriesUtilsTest {
}
}
@Test
@Test(groups = ["entries"])
fun buildLinkLabelTest() {
assertThat(1.toLinkLabel()).isEqualTo("${Constants.LINK_CMD}2")
}
@Test
@Test(groups = ["entries"])
fun buildCommentTest() {
assertThat(buildComment(0, 0, comment)).isEqualTo("${Constants.LINK_CMD}1.1: [nick] comment")
}
@Test
@Test(groups = ["entries"])
fun buildLinkTest() {
for (i in links.indices) {
assertThat(
@ -81,7 +81,7 @@ class EntriesUtilsTest {
assertThat(buildLink(0, links.first(), isView = true), "isView = true").contains("[+1]")
}
@Test
@Test(groups = ["entries"])
fun buildTagsTest() {
for (i in links.indices) {
assertThat(

View file

@ -58,7 +58,7 @@ class EntryLinkTest {
listOf("tag1", "tag2", "tag3", "TAG4", "Tag5")
)
@Test
@Test(groups = ["entries"])
fun testAddDeleteComment() {
var i = 0
while (i < 5) {
@ -91,7 +91,7 @@ class EntryLinkTest {
assertThat(entryLink.deleteComment(comment), "comment is already deleted").isFalse()
}
@Test
@Test(groups = ["entries"])
fun testConstructor() {
val tag = "test"
val tags = listOf(SyndCategoryImpl().apply { name = tag })
@ -101,7 +101,7 @@ class EntryLinkTest {
assertThat(link.pinboardTags, "check pinboard tags").isEqualTo("nick,$tag")
}
@Test
@Test(groups = ["entries"])
fun testMatches() {
assertThat(entryLink.matches("mobitopia"), "match mobitopia").isTrue()
assertThat(entryLink.matches("skynx"), "match nick").isTrue()
@ -112,7 +112,7 @@ class EntryLinkTest {
}
@Test
@Test(groups = ["entries"])
fun testTags() {
val tags: List<SyndCategory> = entryLink.tags
for ((i, tag) in tags.withIndex()) {

View file

@ -61,7 +61,7 @@ class FeedMgrTest {
entries.backlogs = "https://www.mobitopia.org/mobibot/logs"
}
@Test
@Test(groups = ["entries"])
fun testFeedMgr() {
// Load the feed
assertThat(FeedsMgr.loadFeed(entries), "pubDate").isEqualTo("2021-10-31")

View file

@ -44,7 +44,7 @@ import org.testng.annotations.Test
* The `CalcTest` class.
*/
class CalcTest {
@Test
@Test(groups = ["modules"])
fun testCalculate() {
assertThat(calculate("1 + 1"), "calculate(1+1)").isEqualTo("1+1 = ${2.bold()}")
assertThat(calculate("1 -3"), "calculate(1 -3)").isEqualTo("1-3 = ${(-2).bold()}")

View file

@ -53,7 +53,7 @@ class CryptoPricesTest {
loadCurrencies()
}
@Test
@Test(groups = ["modules"])
@Throws(ModuleException::class)
fun testMarketPrice() {
var price = currentPrice(listOf("BTC"))
@ -71,7 +71,7 @@ class CryptoPricesTest {
}
}
@Test
@Test(groups = ["modules"])
fun testGetCurrencyName() {
assertThat(getCurrencyName("USD")).isEqualTo("US Dollar")
assertThat(getCurrencyName("EUR")).isEqualTo("Euro")

View file

@ -56,7 +56,7 @@ class CurrencyConverterTest {
loadSymbols()
}
@Test
@Test(groups = ["modules"])
fun testConvertCurrency() {
assertThat(
convertCurrency("100 USD to EUR").msg,

View file

@ -39,7 +39,7 @@ import assertk.assertions.matches
import org.testng.annotations.Test
class DiceTest {
@Test
@Test(groups = ["modules"])
fun testRoll() {
assertThat(Dice.roll(1, 1), "1d1").isEqualTo("\u00021\u0002")
assertThat(Dice.roll(2, 1), "2d1")

View file

@ -51,7 +51,7 @@ import org.testng.annotations.Test
* The `GoogleSearchTest` class.
*/
class GoogleSearchTest : LocalProperties() {
@Test
@Test(groups = ["modules"])
fun testAPIKeys() {
assertThat(
searchGoogle("", "apikey", "cssKey").first(),
@ -65,7 +65,7 @@ class GoogleSearchTest : LocalProperties() {
.isInstanceOf(ModuleException::class.java).hasNoCause()
}
@Test(groups = ["no-ci"])
@Test(groups = ["no-ci", "modules"])
@Throws(ModuleException::class)
fun testSearchGoogle() {
val apiKey = getProperty(GoogleSearch.GOOGLE_API_KEY_PROP)

View file

@ -42,7 +42,7 @@ import org.testng.annotations.Test
* The `JokeTest` class.
*/
class JokeTest {
@Test
@Test(groups = ["modules"])
@Throws(ModuleException::class)
fun testRandomJoke() {
assertThat(randomJoke().msg, "randomJoke() > 0").all {

View file

@ -42,7 +42,7 @@ import org.testng.annotations.Test
* The `Lookup Test` class.
*/
class LookupTest {
@Test
@Test(groups = ["modules"])
@Throws(Exception::class)
fun testLookup() {
var result = nslookup("apple.com")
@ -52,7 +52,7 @@ class LookupTest {
assertThat(result, "lookup(204.122.17.9)").contains("nix3.thauvin.us")
}
@Test
@Test(groups = ["modules"])
@Throws(Exception::class)
fun testWhois() {
val result = whois("17.178.96.59", Lookup.WHOIS_HOST)

View file

@ -74,7 +74,7 @@ class ModuleExceptionTest {
assertThat(e, "get message").hasMessage(message)
}
@Test
@Test(groups = ["modules"])
fun testSanitizeMessage() {
val apiKey = "1234567890"
var e = ModuleException(debugMessage, message, IOException("URL http://foo.com?apiKey=$apiKey&userID=me"))

View file

@ -41,12 +41,12 @@ import org.testng.annotations.Test
* The `PingTest` class.
*/
class PingTest {
@Test
@Test(groups = ["modules"])
fun testPingsArray() {
assertThat(Ping.PINGS, "Pings array is not empty.").isNotEmpty()
}
@Test
@Test(groups = ["modules"])
fun testRandomPing() {
for (i in 0..9) {
assertThat(Ping.PINGS, "Random ping $i").contains(randomPing())

View file

@ -37,7 +37,7 @@ import assertk.assertions.isEqualTo
import org.testng.annotations.Test
class RockPaperScissorsTest {
@Test
@Test(groups = ["modules"])
fun testWinLoseOrDraw() {
assertThat(RockPaperScissors.winLoseOrDraw("scissors", "paper"), "scissors vs. paper").isEqualTo("win")
assertThat(RockPaperScissors.winLoseOrDraw("paper", "rock"), "paper vs. rock").isEqualTo("win")

View file

@ -55,7 +55,7 @@ class StockQuoteTest : LocalProperties() {
return "${label}:[ ]+[0-9.]+".prependIndent()
}
@Test
@Test(groups = ["modules"])
@Throws(ModuleException::class)
fun testGetQuote() {
val apiKey = getProperty(StockQuote.ALPHAVANTAGE_API_KEY_PROP)

View file

@ -54,7 +54,7 @@ class TwitterTest : LocalProperties() {
}
}
@Test
@Test(groups = ["modules"])
@Throws(ModuleException::class)
fun testPostTwitter() {
val msg = "Testing Twitter API from $ci"

View file

@ -55,13 +55,13 @@ import org.testng.annotations.Test
* The `Weather2Test` class.
*/
class Weather2Test : LocalProperties() {
@Test
@Test(groups = ["modules"])
fun testFtoC() {
val t = ftoC(32.0)
assertThat(t.second, "32 °F is 0 °C").isEqualTo(0)
}
@Test
@Test(groups = ["modules"])
fun testGetCountry() {
assertThat(getCountry("foo"), "not a country").isEqualTo(OWM.Country.UNITED_STATES)
assertThat(getCountry("fr"), "fr is france").isEqualTo(OWM.Country.FRANCE)
@ -73,13 +73,13 @@ class Weather2Test : LocalProperties() {
}
}
@Test
@Test(groups = ["modules"])
fun testMphToKmh() {
val w = mphToKmh(0.62)
assertThat(w.second, "0.62 mph is 1 km/h").isEqualTo(1)
}
@Test
@Test(groups = ["modules"])
@Throws(ModuleException::class)
fun testWeather() {
var messages = getWeather("98204", getProperty(OWM_API_KEY_PROP))

View file

@ -41,7 +41,7 @@ import net.thauvin.erik.mobibot.LocalProperties
import org.testng.annotations.Test
class WolframAlphaTest : LocalProperties() {
@Test
@Test(groups = ["modules"])
@Throws(ModuleException::class)
fun queryWolframTest() {
val apiKey = getProperty(WolframAlpha.WOLFRAM_API_KEY_PROP)

View file

@ -48,7 +48,7 @@ import java.time.ZoneId
* The `WordTimeTest` class.
*/
class WordTimeTest {
@Test
@Test(groups = ["modules"])
fun testTime() {
assertThat(time(), "no zone").matches(
("The time is ${Colors.BOLD}\\d{1,2}:\\d{2}${Colors.BOLD} " +
@ -63,7 +63,7 @@ class WordTimeTest {
assertThat(time("BEAT"), BEATS_KEYWORD).matches("[\\w ]+ .?@\\d{3}+.? .beats".toRegex())
}
@Test
@Test(groups = ["modules"])
fun testZones() {
COUNTRIES_MAP.filter { it.value != BEATS_KEYWORD }.forEach {
assertThat { ZoneId.of(it.value) }.isSuccess()