From d62de239369d381290acda2546471633cca695af Mon Sep 17 00:00:00 2001 From: Daoortor Date: Fri, 12 Jul 2024 23:40:04 +0200 Subject: [PATCH] better NotImplementedError handling --- AlmostDone/CompleteTheProject/test/Tests.kt | 8 +++++++ AlmostDone/MultiRowStrings/test/Tests.kt | 3 +++ AlmostDone/NullSafety/test/Tests.kt | 3 +++ AlmostDone/NullSafetyPartTwo/test/Tests.kt | 3 +++ AlmostDone/StringFunctions/test/Tests.kt | 3 +++ .../StringFunctionsPartTwo/test/Tests.kt | 3 +++ AlmostDone/When/test/Tests.kt | 3 +++ .../applyBordersFilterFunction/test/Tests.kt | 3 +++ .../choosePictureFunction/test/Tests.kt | 3 +++ AlmostDone/safeReadLineFunction/test/Tests.kt | 3 +++ Chat/askFirstQuestion/test/Tests.kt | 5 ++++ Chat/askSecondQuestion/test/Tests.kt | 5 ++++ Chat/completeTheProject/test/Tests.kt | 5 ++++ Hangman/CompleteTheProject/test/Tests.kt | 13 +++++++---- Hangman/Core/test/Tests.kt | 3 +++ Hangman/generateSecretFunction/test/Tests.kt | 3 +++ Hangman/getHiddenSecretFunction/test/Tests.kt | 3 +++ Hangman/getRoundResultsFunction/test/Tests.kt | 3 +++ Hangman/isCompleteFunction/test/Tests.kt | 3 +++ Hangman/isCorrectInputFunction/test/Tests.kt | 3 +++ Hangman/safeUserInputFunction/test/Tests.kt | 3 +++ LastPush/CanvasGapsGenerator/test/Tests.kt | 3 +++ LastPush/CanvasGenerator/test/Tests.kt | 3 +++ LastPush/CompleteTheProject/test/Tests.kt | 11 +++++++++ .../course/last/push/PreDefinedSymbols.kt | 2 +- LastPush/Helpers/test/Tests.kt | 7 +++++- .../course/last/push/PreDefinedSymbols.kt | 2 +- LastPush/dropTopLineFunction/test/Tests.kt | 3 +++ .../course/last/push/PreDefinedSymbols.kt | 2 +- .../getPatternHeightFunction/test/Tests.kt | 5 ++-- .../repeatHorizontallyFunction/test/Tests.kt | 3 +++ .../CompleteTheProject/test/Tests.kt | 10 ++++++++ .../generateSecretFunction/test/Tests.kt | 9 ++++++++ .../isCorrectInputFunction/test/Tests.kt | 11 +++++++++ .../safeUserInputFunction/test/Tests.kt | 10 +++++++- .../BuiltinFunctions/test/Tests.kt | 5 ++++ .../CompleteTheProject/test/Tests.kt | 4 ++++ .../ProgramEntryPoint/test/Tests.kt | 5 ++++ .../ReadUserInput/test/Tests.kt | 4 ++++ .../Variables/test/Tests.kt | 5 ++++ WarmUp/Collections/test/Tests.kt | 8 +++++++ WarmUp/CollectionsPartTwo/test/Tests.kt | 8 +++++++ WarmUp/CompleteTheProject/test/Tests.kt | 8 +++++++ WarmUp/CustomFunctions/test/Tests.kt | 8 +++++++ WarmUp/If/test/Tests.kt | 8 +++++++ WarmUp/Loops/test/Tests.kt | 8 +++++++ WarmUp/TypesOfVariables/test/Tests.kt | 12 +++++++--- WarmUp/countPartialMatches/test/Tests.kt | 8 +++++++ WarmUp/isCompleteFunction/test/Tests.kt | 8 +++++++ WarmUp/isLostFunction/test/Tests.kt | 10 +++++++- WarmUp/isWinFunction/test/Tests.kt | 8 +++++++ WarmUp/playGameMain/test/Tests.kt | 8 +++++++ WarmUp/printRoundResults/test/Tests.kt | 8 +++++++ .../kotlin/course/gifs/warmup/runners/Game.kt | 5 ++-- utils/src/main/kotlin/util/Util.kt | 23 +++++++++++++++++++ 55 files changed, 308 insertions(+), 18 deletions(-) diff --git a/AlmostDone/CompleteTheProject/test/Tests.kt b/AlmostDone/CompleteTheProject/test/Tests.kt index 9e00dfdb..de51deec 100644 --- a/AlmostDone/CompleteTheProject/test/Tests.kt +++ b/AlmostDone/CompleteTheProject/test/Tests.kt @@ -7,11 +7,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private const val SQUARED = "squared" @@ -115,6 +118,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "$YES$newLineSymbol$SIMBA$newLineSymbol$BORDERS$newLineSymbol") + } + @Test fun testPhotoshopFunction() { mainClass.checkMethod(mainClazz, photoshop) diff --git a/AlmostDone/MultiRowStrings/test/Tests.kt b/AlmostDone/MultiRowStrings/test/Tests.kt index ec62d9cc..658329d5 100644 --- a/AlmostDone/MultiRowStrings/test/Tests.kt +++ b/AlmostDone/MultiRowStrings/test/Tests.kt @@ -4,11 +4,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { diff --git a/AlmostDone/NullSafety/test/Tests.kt b/AlmostDone/NullSafety/test/Tests.kt index d2f9c879..8c92134e 100644 --- a/AlmostDone/NullSafety/test/Tests.kt +++ b/AlmostDone/NullSafety/test/Tests.kt @@ -5,11 +5,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private const val SQUARED = "squared" diff --git a/AlmostDone/NullSafetyPartTwo/test/Tests.kt b/AlmostDone/NullSafetyPartTwo/test/Tests.kt index aaec8516..8f582087 100644 --- a/AlmostDone/NullSafetyPartTwo/test/Tests.kt +++ b/AlmostDone/NullSafetyPartTwo/test/Tests.kt @@ -6,11 +6,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private const val SQUARED = "squared" diff --git a/AlmostDone/StringFunctions/test/Tests.kt b/AlmostDone/StringFunctions/test/Tests.kt index 1220ecea..717b9b7f 100644 --- a/AlmostDone/StringFunctions/test/Tests.kt +++ b/AlmostDone/StringFunctions/test/Tests.kt @@ -3,11 +3,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError(["applySquaredFilter"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/AlmostDone/StringFunctionsPartTwo/test/Tests.kt b/AlmostDone/StringFunctionsPartTwo/test/Tests.kt index d2276ba8..d3e1efcf 100644 --- a/AlmostDone/StringFunctionsPartTwo/test/Tests.kt +++ b/AlmostDone/StringFunctionsPartTwo/test/Tests.kt @@ -3,11 +3,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/AlmostDone/When/test/Tests.kt b/AlmostDone/When/test/Tests.kt index 7ec17b65..694b1b16 100644 --- a/AlmostDone/When/test/Tests.kt +++ b/AlmostDone/When/test/Tests.kt @@ -4,11 +4,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError(["applyBordersFilter", "applySquaredFilter"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private const val WITH_INDENT = diff --git a/AlmostDone/applyBordersFilterFunction/test/Tests.kt b/AlmostDone/applyBordersFilterFunction/test/Tests.kt index e0efdc2a..51f0c7ba 100644 --- a/AlmostDone/applyBordersFilterFunction/test/Tests.kt +++ b/AlmostDone/applyBordersFilterFunction/test/Tests.kt @@ -4,11 +4,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { diff --git a/AlmostDone/choosePictureFunction/test/Tests.kt b/AlmostDone/choosePictureFunction/test/Tests.kt index fb02c868..af73aa95 100644 --- a/AlmostDone/choosePictureFunction/test/Tests.kt +++ b/AlmostDone/choosePictureFunction/test/Tests.kt @@ -6,11 +6,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private const val SQUARED = "squared" diff --git a/AlmostDone/safeReadLineFunction/test/Tests.kt b/AlmostDone/safeReadLineFunction/test/Tests.kt index db8e10be..e6b7ec80 100644 --- a/AlmostDone/safeReadLineFunction/test/Tests.kt +++ b/AlmostDone/safeReadLineFunction/test/Tests.kt @@ -4,12 +4,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import util.Util.newLineSeparator +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Chat/askFirstQuestion/test/Tests.kt b/Chat/askFirstQuestion/test/Tests.kt index 61297480..b5bdc527 100644 --- a/Chat/askFirstQuestion/test/Tests.kt +++ b/Chat/askFirstQuestion/test/Tests.kt @@ -4,7 +4,12 @@ import org.junit.jupiter.api.Test import util.Util import util.Util.DEFAULT_USER_INPUT import util.runMainFunction +import org.junit.jupiter.api.extension.ExtendWith +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/Chat/askSecondQuestion/test/Tests.kt b/Chat/askSecondQuestion/test/Tests.kt index b5a64539..aaac7b5d 100644 --- a/Chat/askSecondQuestion/test/Tests.kt +++ b/Chat/askSecondQuestion/test/Tests.kt @@ -4,7 +4,12 @@ import org.junit.jupiter.api.Test import util.Util import util.Util.DEFAULT_USER_INPUT import util.runMainFunction +import org.junit.jupiter.api.extension.ExtendWith +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/Chat/completeTheProject/test/Tests.kt b/Chat/completeTheProject/test/Tests.kt index be76e309..0094a4fc 100644 --- a/Chat/completeTheProject/test/Tests.kt +++ b/Chat/completeTheProject/test/Tests.kt @@ -4,7 +4,12 @@ import org.junit.jupiter.api.Test import util.Util import util.Util.DEFAULT_USER_INPUT import util.runMainFunction +import org.junit.jupiter.api.extension.ExtendWith +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/Hangman/CompleteTheProject/test/Tests.kt b/Hangman/CompleteTheProject/test/Tests.kt index c027006b..50f466a8 100644 --- a/Hangman/CompleteTheProject/test/Tests.kt +++ b/Hangman/CompleteTheProject/test/Tests.kt @@ -1,7 +1,4 @@ -import jetbrains.kotlin.course.hangman.generateNewUserWord -import jetbrains.kotlin.course.hangman.separator -import jetbrains.kotlin.course.hangman.underscore -import jetbrains.kotlin.course.hangman.words +import jetbrains.kotlin.course.hangman.* import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.invokeWithoutArgs import org.jetbrains.academy.test.system.core.models.classes.TestClass @@ -9,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.api.Test import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -109,6 +109,11 @@ class Test { ) } + @Test + fun smokeTest() { + runMainFunction(::main, List(maxAttemptsCount + 1) { "A$newLineSymbol" }.joinToString("")) + } + @ParameterizedTest @MethodSource("functions") fun testFunctions(function: TestMethod) { diff --git a/Hangman/Core/test/Tests.kt b/Hangman/Core/test/Tests.kt index 105ce457..abc6a889 100644 --- a/Hangman/Core/test/Tests.kt +++ b/Hangman/Core/test/Tests.kt @@ -5,11 +5,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Hangman/generateSecretFunction/test/Tests.kt b/Hangman/generateSecretFunction/test/Tests.kt index 3cc2bdb9..d6f6e581 100644 --- a/Hangman/generateSecretFunction/test/Tests.kt +++ b/Hangman/generateSecretFunction/test/Tests.kt @@ -7,12 +7,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.api.Test import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Hangman/getHiddenSecretFunction/test/Tests.kt b/Hangman/getHiddenSecretFunction/test/Tests.kt index 4a01eef5..cd3fa267 100644 --- a/Hangman/getHiddenSecretFunction/test/Tests.kt +++ b/Hangman/getHiddenSecretFunction/test/Tests.kt @@ -8,12 +8,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.api.Test import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Hangman/getRoundResultsFunction/test/Tests.kt b/Hangman/getRoundResultsFunction/test/Tests.kt index 7a98203c..4541f488 100644 --- a/Hangman/getRoundResultsFunction/test/Tests.kt +++ b/Hangman/getRoundResultsFunction/test/Tests.kt @@ -9,12 +9,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.api.Test import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Hangman/isCompleteFunction/test/Tests.kt b/Hangman/isCompleteFunction/test/Tests.kt index 6f415b6b..6187a3bf 100644 --- a/Hangman/isCompleteFunction/test/Tests.kt +++ b/Hangman/isCompleteFunction/test/Tests.kt @@ -5,11 +5,14 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Hangman/isCorrectInputFunction/test/Tests.kt b/Hangman/isCorrectInputFunction/test/Tests.kt index 4391da8d..c3c59f0b 100644 --- a/Hangman/isCorrectInputFunction/test/Tests.kt +++ b/Hangman/isCorrectInputFunction/test/Tests.kt @@ -8,12 +8,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.api.Test import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/Hangman/safeUserInputFunction/test/Tests.kt b/Hangman/safeUserInputFunction/test/Tests.kt index ad589ad6..349d8ba2 100644 --- a/Hangman/safeUserInputFunction/test/Tests.kt +++ b/Hangman/safeUserInputFunction/test/Tests.kt @@ -8,12 +8,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.api.Test import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/LastPush/CanvasGapsGenerator/test/Tests.kt b/LastPush/CanvasGapsGenerator/test/Tests.kt index 509edea2..6574df3e 100644 --- a/LastPush/CanvasGapsGenerator/test/Tests.kt +++ b/LastPush/CanvasGapsGenerator/test/Tests.kt @@ -7,12 +7,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/LastPush/CanvasGenerator/test/Tests.kt b/LastPush/CanvasGenerator/test/Tests.kt index 23c10081..283bd33b 100644 --- a/LastPush/CanvasGenerator/test/Tests.kt +++ b/LastPush/CanvasGenerator/test/Tests.kt @@ -7,12 +7,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/LastPush/CompleteTheProject/test/Tests.kt b/LastPush/CompleteTheProject/test/Tests.kt index 978052d4..a85169de 100644 --- a/LastPush/CompleteTheProject/test/Tests.kt +++ b/LastPush/CompleteTheProject/test/Tests.kt @@ -2,6 +2,7 @@ import jetbrains.kotlin.course.last.push.* import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.Test import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.params.ParameterizedTest @@ -10,6 +11,8 @@ import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @@ -128,6 +131,14 @@ class Test { }.toArguments() } + @Test + fun smokeTest() { + runMainFunction( + ::main, + "$YES$newLineSymbol$CUBE$newLineSymbol$CANVAS${newLineSymbol}5${newLineSymbol}5$newLineSymbol" + ) + } + @Test fun fillPatternRowFunction() { mainClass.checkMethod(mainClazz, fillPatternRowMethod) diff --git a/LastPush/Helpers/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt b/LastPush/Helpers/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt index 0ddfebf1..207dae44 100644 --- a/LastPush/Helpers/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt +++ b/LastPush/Helpers/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt @@ -3,7 +3,7 @@ package jetbrains.kotlin.course.last.push val separator = ' ' -val newLineSymbol = System.lineSeparator().replace("\r\n", "\n") +val newLineSymbol = System.lineSeparator() fun getPatternWidth(pattern: String) = pattern.lines().maxOfOrNull { it.length } ?: 0 diff --git a/LastPush/Helpers/test/Tests.kt b/LastPush/Helpers/test/Tests.kt index 8ca40659..1f37e8b7 100644 --- a/LastPush/Helpers/test/Tests.kt +++ b/LastPush/Helpers/test/Tests.kt @@ -5,12 +5,17 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource -import util.* +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension +import util.throwInternalCourseError import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/LastPush/PatternsGenerator/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt b/LastPush/PatternsGenerator/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt index 0ddfebf1..207dae44 100644 --- a/LastPush/PatternsGenerator/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt +++ b/LastPush/PatternsGenerator/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt @@ -3,7 +3,7 @@ package jetbrains.kotlin.course.last.push val separator = ' ' -val newLineSymbol = System.lineSeparator().replace("\r\n", "\n") +val newLineSymbol = System.lineSeparator() fun getPatternWidth(pattern: String) = pattern.lines().maxOfOrNull { it.length } ?: 0 diff --git a/LastPush/dropTopLineFunction/test/Tests.kt b/LastPush/dropTopLineFunction/test/Tests.kt index 7313d20a..a6e1ddba 100644 --- a/LastPush/dropTopLineFunction/test/Tests.kt +++ b/LastPush/dropTopLineFunction/test/Tests.kt @@ -4,12 +4,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/LastPush/getPatternHeightFunction/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt b/LastPush/getPatternHeightFunction/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt index 0ddfebf1..207dae44 100644 --- a/LastPush/getPatternHeightFunction/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt +++ b/LastPush/getPatternHeightFunction/src/main/kotlin/jetbrains/kotlin/course/last/push/PreDefinedSymbols.kt @@ -3,7 +3,7 @@ package jetbrains.kotlin.course.last.push val separator = ' ' -val newLineSymbol = System.lineSeparator().replace("\r\n", "\n") +val newLineSymbol = System.lineSeparator() fun getPatternWidth(pattern: String) = pattern.lines().maxOfOrNull { it.length } ?: 0 diff --git a/LastPush/getPatternHeightFunction/test/Tests.kt b/LastPush/getPatternHeightFunction/test/Tests.kt index 8c631ed3..88556f62 100644 --- a/LastPush/getPatternHeightFunction/test/Tests.kt +++ b/LastPush/getPatternHeightFunction/test/Tests.kt @@ -1,16 +1,17 @@ -import jetbrains.kotlin.course.last.push.ball import jetbrains.kotlin.course.last.push.newLineSymbol import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* -import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/LastPush/repeatHorizontallyFunction/test/Tests.kt b/LastPush/repeatHorizontallyFunction/test/Tests.kt index cf53a43a..7ae07c9e 100644 --- a/LastPush/repeatHorizontallyFunction/test/Tests.kt +++ b/LastPush/repeatHorizontallyFunction/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic diff --git a/MastermindAdvanced/CompleteTheProject/test/Tests.kt b/MastermindAdvanced/CompleteTheProject/test/Tests.kt index c99b326e..3b26c14c 100644 --- a/MastermindAdvanced/CompleteTheProject/test/Tests.kt +++ b/MastermindAdvanced/CompleteTheProject/test/Tests.kt @@ -1,15 +1,20 @@ +import jetbrains.kotlin.course.mastermind.advanced.generateSecret +import jetbrains.kotlin.course.mastermind.advanced.main import jetbrains.kotlin.course.mastermind.advanced.newLineSymbol import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -84,6 +89,11 @@ class Test { ) } + @Test + fun smokeTest() { + runMainFunction(::main, List(4) { generateSecret(4, "ABCDEFGH") + newLineSymbol }.joinToString("")) + } + @Test fun testplayGameFunction() { mainClass.checkMethod(mainClazz, playGameMethod) diff --git a/MastermindAdvanced/generateSecretFunction/test/Tests.kt b/MastermindAdvanced/generateSecretFunction/test/Tests.kt index 08de036d..1a2b95d1 100644 --- a/MastermindAdvanced/generateSecretFunction/test/Tests.kt +++ b/MastermindAdvanced/generateSecretFunction/test/Tests.kt @@ -1,13 +1,17 @@ +import jetbrains.kotlin.course.mastermind.advanced.* import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -64,6 +68,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, List(4) { generateSecret(4, "ABCDEFGH") + newLineSymbol }.joinToString("")) + } + @ParameterizedTest @MethodSource("secretProperties") fun testGenerateSecretImplementation( diff --git a/MastermindAdvanced/isCorrectInputFunction/test/Tests.kt b/MastermindAdvanced/isCorrectInputFunction/test/Tests.kt index bbd5b3ef..854fa75a 100644 --- a/MastermindAdvanced/isCorrectInputFunction/test/Tests.kt +++ b/MastermindAdvanced/isCorrectInputFunction/test/Tests.kt @@ -1,13 +1,19 @@ +import jetbrains.kotlin.course.mastermind.advanced.generateSecret +import jetbrains.kotlin.course.mastermind.advanced.main +import jetbrains.kotlin.course.mastermind.advanced.newLineSymbol import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -74,6 +80,11 @@ class Test { ) } + @Test + fun smokeTest() { + runMainFunction(::main, List(4) { generateSecret(4, "ABCDEFGH") + newLineSymbol }.joinToString("")) + } + @Test fun testIsCorrectInputFunction() { mainClass.checkMethod(mainClazz, isCorrectInputMethod) diff --git a/MastermindAdvanced/safeUserInputFunction/test/Tests.kt b/MastermindAdvanced/safeUserInputFunction/test/Tests.kt index 3666daaf..a6f2c276 100644 --- a/MastermindAdvanced/safeUserInputFunction/test/Tests.kt +++ b/MastermindAdvanced/safeUserInputFunction/test/Tests.kt @@ -1,15 +1,18 @@ -import jetbrains.kotlin.course.mastermind.advanced.newLineSymbol +import jetbrains.kotlin.course.mastermind.advanced.* import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -84,6 +87,11 @@ class Test { ) } + @Test + fun smokeTest() { + runMainFunction(::main, List(4) { generateSecret(4, "ABCDEFGH") + newLineSymbol }.joinToString("")) + } + @Test fun testSafeUserInputFunction() { mainClass.checkMethod(mainClazz, safeUserInputMethod) diff --git a/TheFirstDateWithProgramming/BuiltinFunctions/test/Tests.kt b/TheFirstDateWithProgramming/BuiltinFunctions/test/Tests.kt index 2c0decd7..10f83010 100644 --- a/TheFirstDateWithProgramming/BuiltinFunctions/test/Tests.kt +++ b/TheFirstDateWithProgramming/BuiltinFunctions/test/Tests.kt @@ -3,7 +3,12 @@ import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import util.Util import util.runMainFunction +import org.junit.jupiter.api.extension.ExtendWith +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/TheFirstDateWithProgramming/CompleteTheProject/test/Tests.kt b/TheFirstDateWithProgramming/CompleteTheProject/test/Tests.kt index 98371869..0a692317 100644 --- a/TheFirstDateWithProgramming/CompleteTheProject/test/Tests.kt +++ b/TheFirstDateWithProgramming/CompleteTheProject/test/Tests.kt @@ -7,7 +7,11 @@ import org.junit.jupiter.api.Test import util.Util import util.Util.DEFAULT_USER_INPUT import util.runMainFunction +import org.junit.jupiter.api.extension.ExtendWith +import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/TheFirstDateWithProgramming/ProgramEntryPoint/test/Tests.kt b/TheFirstDateWithProgramming/ProgramEntryPoint/test/Tests.kt index 355ee1f6..917e53c4 100644 --- a/TheFirstDateWithProgramming/ProgramEntryPoint/test/Tests.kt +++ b/TheFirstDateWithProgramming/ProgramEntryPoint/test/Tests.kt @@ -1,9 +1,14 @@ import jetbrains.kotlin.course.first.date.main import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension import util.Util import util.runMainFunction +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/TheFirstDateWithProgramming/ReadUserInput/test/Tests.kt b/TheFirstDateWithProgramming/ReadUserInput/test/Tests.kt index 7e3cf56b..67798fcd 100644 --- a/TheFirstDateWithProgramming/ReadUserInput/test/Tests.kt +++ b/TheFirstDateWithProgramming/ReadUserInput/test/Tests.kt @@ -4,7 +4,11 @@ import org.junit.jupiter.api.Test import util.Util import util.Util.DEFAULT_USER_INPUT import util.runMainFunction +import org.junit.jupiter.api.extension.ExtendWith +import util.* +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testSolution() { diff --git a/TheFirstDateWithProgramming/Variables/test/Tests.kt b/TheFirstDateWithProgramming/Variables/test/Tests.kt index 9bbd7227..453394ff 100644 --- a/TheFirstDateWithProgramming/Variables/test/Tests.kt +++ b/TheFirstDateWithProgramming/Variables/test/Tests.kt @@ -6,7 +6,12 @@ import util.Util import util.checkListOfVariables import util.runMainFunction import java.io.File +import org.junit.jupiter.api.extension.ExtendWith +import util.HandleNotImplementedError +import util.HandleNotImplementedErrorExtension +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { @Test fun testVariablesInSolution() { diff --git a/WarmUp/Collections/test/Tests.kt b/WarmUp/Collections/test/Tests.kt index 26da3e96..b9ff2d9d 100644 --- a/WarmUp/Collections/test/Tests.kt +++ b/WarmUp/Collections/test/Tests.kt @@ -4,6 +4,7 @@ import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.invokeWithoutArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.Test import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.params.ParameterizedTest @@ -12,6 +13,8 @@ import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -49,6 +52,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @ParameterizedTest @MethodSource("sequences") fun testCountExactMatchesImplementation( diff --git a/WarmUp/CollectionsPartTwo/test/Tests.kt b/WarmUp/CollectionsPartTwo/test/Tests.kt index ca1c5452..01478884 100644 --- a/WarmUp/CollectionsPartTwo/test/Tests.kt +++ b/WarmUp/CollectionsPartTwo/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -49,6 +52,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @Test fun testCountAllMatchesFunction() { mainClass.checkMethod(mainClazz, countAllMatches) diff --git a/WarmUp/CompleteTheProject/test/Tests.kt b/WarmUp/CompleteTheProject/test/Tests.kt index 2ffe833f..d825cad2 100644 --- a/WarmUp/CompleteTheProject/test/Tests.kt +++ b/WarmUp/CompleteTheProject/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -85,6 +88,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @Test fun testPlayGameFunction() { mainClass.checkMethod(mainClazz, playGameMethod) diff --git a/WarmUp/CustomFunctions/test/Tests.kt b/WarmUp/CustomFunctions/test/Tests.kt index 4a06c322..20f2ada8 100644 --- a/WarmUp/CustomFunctions/test/Tests.kt +++ b/WarmUp/CustomFunctions/test/Tests.kt @@ -5,9 +5,12 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches", "countExactMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private lateinit var mainClazz: Class<*> @@ -19,6 +22,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "") + } + @Test fun testGetGameRulesFunction() { mainClass.checkMethod(mainClazz, getGameRulesMethod) diff --git a/WarmUp/If/test/Tests.kt b/WarmUp/If/test/Tests.kt index 045dffcd..2a53ce61 100644 --- a/WarmUp/If/test/Tests.kt +++ b/WarmUp/If/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches", "countExactMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -30,6 +33,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @ParameterizedTest @MethodSource("inputsToCheck") fun testIsCompleteImplementation( diff --git a/WarmUp/Loops/test/Tests.kt b/WarmUp/Loops/test/Tests.kt index b62d5b37..006c038a 100644 --- a/WarmUp/Loops/test/Tests.kt +++ b/WarmUp/Loops/test/Tests.kt @@ -4,11 +4,14 @@ import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.invokeWithoutArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.Test import org.junit.jupiter.api.BeforeAll import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches", "countExactMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private lateinit var mainClazz: Class<*> @@ -20,6 +23,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "") + } + @Test fun testPlayGameFunction() { mainClass.checkMethod(mainClazz, playGameMethod) diff --git a/WarmUp/TypesOfVariables/test/Tests.kt b/WarmUp/TypesOfVariables/test/Tests.kt index 4cd88691..1638de9a 100644 --- a/WarmUp/TypesOfVariables/test/Tests.kt +++ b/WarmUp/TypesOfVariables/test/Tests.kt @@ -5,11 +5,12 @@ import org.jetbrains.academy.test.system.core.models.variable.TestVariable import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test -import util.checkListOfVariables -import util.runMainFunction -import util.throwInternalCourseError +import org.junit.jupiter.api.extension.ExtendWith +import util.* import java.io.File +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private lateinit var mainClazz: Class<*> @@ -21,6 +22,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "") + } + @Test fun testGetGameRulesFunction() { mainClass.checkMethod(mainClazz, getGameRulesMethod) diff --git a/WarmUp/countPartialMatches/test/Tests.kt b/WarmUp/countPartialMatches/test/Tests.kt index 327d488f..32b9deb0 100644 --- a/WarmUp/countPartialMatches/test/Tests.kt +++ b/WarmUp/countPartialMatches/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -49,6 +52,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @ParameterizedTest @MethodSource("sequences") fun testCountPartialMatchesImplementation( diff --git a/WarmUp/isCompleteFunction/test/Tests.kt b/WarmUp/isCompleteFunction/test/Tests.kt index a2522596..75f9dd74 100644 --- a/WarmUp/isCompleteFunction/test/Tests.kt +++ b/WarmUp/isCompleteFunction/test/Tests.kt @@ -6,9 +6,12 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches", "countExactMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private lateinit var mainClazz: Class<*> @@ -20,6 +23,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "") + } + @Test fun testIsCompleteFunction() { val userMethod = mainClass.findMethod(mainClazz, isCompleteMethod) diff --git a/WarmUp/isLostFunction/test/Tests.kt b/WarmUp/isLostFunction/test/Tests.kt index cbbdf76a..70c385ab 100644 --- a/WarmUp/isLostFunction/test/Tests.kt +++ b/WarmUp/isLostFunction/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -59,6 +62,11 @@ class Test { ) } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @Test fun testIsLostFunction() { mainClass.checkMethod(mainClazz, isLostMethod) @@ -118,7 +126,7 @@ class Test { userMethod.invoke(mainClazz, guess, secret) val actualOutput = baos.toString("UTF-8").replaceLineSeparator() Assertions.assertEquals(expectedOutput, actualOutput) { errorMessage } - } catch(e: InvocationTargetException) { + } catch (e: InvocationTargetException) { Assertions.assertTrue(false) { errorMessage } } } diff --git a/WarmUp/isWinFunction/test/Tests.kt b/WarmUp/isWinFunction/test/Tests.kt index cac87c06..f4d939cc 100644 --- a/WarmUp/isWinFunction/test/Tests.kt +++ b/WarmUp/isWinFunction/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -59,6 +62,11 @@ class Test { ) } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @Test fun testIsWinFunction() { mainClass.checkMethod(mainClazz, isWinMethod) diff --git a/WarmUp/playGameMain/test/Tests.kt b/WarmUp/playGameMain/test/Tests.kt index 452b8b29..5d2c761b 100644 --- a/WarmUp/playGameMain/test/Tests.kt +++ b/WarmUp/playGameMain/test/Tests.kt @@ -4,11 +4,14 @@ import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.invokeWithoutArgs import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.Test import org.junit.jupiter.api.BeforeAll import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError(["countPartialMatches", "countExactMatches"]) +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { private lateinit var mainClazz: Class<*> @@ -20,6 +23,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @Test fun testPlayGameFunction() { mainClass.checkMethod(mainClazz, playGameMethod) diff --git a/WarmUp/printRoundResults/test/Tests.kt b/WarmUp/printRoundResults/test/Tests.kt index 09c50ea9..068f1bb4 100644 --- a/WarmUp/printRoundResults/test/Tests.kt +++ b/WarmUp/printRoundResults/test/Tests.kt @@ -6,12 +6,15 @@ import org.jetbrains.academy.test.system.core.models.classes.findClassSafe import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import util.* import java.lang.reflect.InvocationTargetException +@HandleNotImplementedError +@ExtendWith(HandleNotImplementedErrorExtension::class) class Test { companion object { @JvmStatic @@ -49,6 +52,11 @@ class Test { } } + @Test + fun smokeTest() { + runMainFunction(::main, "ABCD$newLineSymbol") + } + @Test fun testPrintRoundResultsFunction() { mainClass.checkMethod(mainClazz, printRoundResultsMethod) diff --git a/gifs/src/main/kotlin/jetbrains/kotlin/course/gifs/warmup/runners/Game.kt b/gifs/src/main/kotlin/jetbrains/kotlin/course/gifs/warmup/runners/Game.kt index 43754b52..5e3f2afc 100644 --- a/gifs/src/main/kotlin/jetbrains/kotlin/course/gifs/warmup/runners/Game.kt +++ b/gifs/src/main/kotlin/jetbrains/kotlin/course/gifs/warmup/runners/Game.kt @@ -1,13 +1,12 @@ package jetbrains.kotlin.course.gifs.warmup.runners -import jetbrains.kotlin.course.mastermind.advanced.getGameRules -import jetbrains.kotlin.course.mastermind.advanced.playGame +import jetbrains.kotlin.course.mastermind.advanced.* fun main() { val wordLength = 4 val maxAttemptsCount = 3 val secretExample = "ACEB" val alphabet = "ABCDEFGH" - println(getGameRules(wordLength, maxAttemptsCount, secretExample).replace(". ", ".\n")) + println(getGameRules(wordLength, maxAttemptsCount, secretExample).replace(". ", ".$newLineSymbol")) playGame("BBDH", wordLength, maxAttemptsCount, alphabet) } diff --git a/utils/src/main/kotlin/util/Util.kt b/utils/src/main/kotlin/util/Util.kt index d288e1d8..367382a5 100644 --- a/utils/src/main/kotlin/util/Util.kt +++ b/utils/src/main/kotlin/util/Util.kt @@ -5,6 +5,8 @@ import org.jetbrains.academy.test.system.core.invokeWithArgs import org.jetbrains.academy.test.system.core.invokeWithoutArgs import org.jetbrains.academy.test.system.core.models.method.TestMethod import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.extension.ExtensionContext +import org.junit.jupiter.api.extension.TestExecutionExceptionHandler import util.Util.newLineSeparator import java.io.ByteArrayOutputStream import java.io.PrintStream @@ -84,3 +86,24 @@ fun checkReadLineFunctions( "function ${testMethod.name} should return $output" ) } + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.RUNTIME) +annotation class HandleNotImplementedError(val shouldNotBeImplemented: Array = []) + +class HandleNotImplementedErrorExtension : TestExecutionExceptionHandler { + override fun handleTestExecutionException(context: ExtensionContext, throwable: Throwable): Nothing = if (throwable.javaClass.name == "kotlin.NotImplementedError") { + val notImplementedMethodName = throwable.stackTrace.first().methodName + val testClass = context.testClass.orElse(null) + val annotation = testClass?.getAnnotation(HandleNotImplementedError::class.java) + error(if (annotation?.shouldNotBeImplemented?.contains(notImplementedMethodName) == true) { + """In test: ${context.displayName} + $notImplementedMethodName shouldn't be implemented, but it's called""".trimMargin() + } else { + """In test: ${context.displayName} + $notImplementedMethodName is not implemented, but should be implemented""".trimMargin() + }) + } else { + throw throwable + } +}