Extract test instance lifecycle annotation

This commit is contained in:
Mike Cifelli 2018-10-20 11:18:21 -04:00
parent 347857fbb5
commit 0efae35391
31 changed files with 78 additions and 91 deletions

View File

@ -13,17 +13,16 @@ import org.junit.Test
import org.junit.contrib.java.lang.system.ExpectedSystemExit
import org.junit.contrib.java.lang.system.SystemErrRule
import org.junit.contrib.java.lang.system.SystemOutRule
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import terminal.TerminalConfiguration
import terminal.VirtualTerminalInteractor
import testutil.LispTestInstance
import testutil.SymbolAndFunctionCleaner
import java.io.PipedInputStream
import java.io.PipedOutputStream
import java.text.MessageFormat.format
import java.util.concurrent.CountDownLatch
@TestInstance(PER_CLASS)
@LispTestInstance
class MainTest : SymbolAndFunctionCleaner() {
companion object {

View File

@ -5,10 +5,10 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class RuntimeEnvironmentTest {
companion object {

View File

@ -8,12 +8,12 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import java.io.ByteArrayOutputStream
import java.io.PrintStream
@TestInstance(PER_CLASS)
@LispTestInstance
class ErrorManagerTest {
companion object {

View File

@ -3,10 +3,9 @@ package file
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class FilePositionTrackerTest {
companion object {

View File

@ -7,17 +7,16 @@ import function.ArgumentValidator.TooManyArgumentsException
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Cons
import sexpression.LispString
import sexpression.Nil
import sexpression.SExpression
import sexpression.Symbol
import sexpression.Symbol.Companion.T
import testutil.LispTestInstance
import testutil.TestUtilities.assertIsErrorWithMessage
@TestInstance(PER_CLASS)
@LispTestInstance
class ArgumentValidatorTest {
companion object {

View File

@ -2,12 +2,11 @@ package function
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Cons
import sexpression.Nil
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class LispFunctionTest {
@Test

View File

@ -2,12 +2,11 @@ package function
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Cons
import sexpression.Nil
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class LispSpecialFunctionTest {
@Test

View File

@ -6,16 +6,15 @@ import function.UserDefinedFunction.IllegalKeywordRestPositionException
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Cons
import sexpression.LispNumber
import sexpression.Nil
import sexpression.Symbol
import testutil.LispTestInstance
import testutil.TestUtilities.assertIsErrorWithMessage
import testutil.TestUtilities.assertSExpressionsMatch
@TestInstance(PER_CLASS)
@LispTestInstance
class UserDefinedFunctionTest {
companion object {

View File

@ -13,17 +13,16 @@ import function.builtin.special.RECUR.RecurNotInTailPositionException
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import org.junit.jupiter.api.fail
import sexpression.Nil
import testutil.LispTestInstance
import testutil.SymbolAndFunctionCleaner
import testutil.TestUtilities.assertIsErrorWithMessage
import testutil.TestUtilities.assertSExpressionsMatch
import testutil.TestUtilities.evaluateString
import testutil.TestUtilities.parseString
@TestInstance(PER_CLASS)
@LispTestInstance
class EvalTest : SymbolAndFunctionCleaner() {
@Test

View File

@ -5,12 +5,12 @@ import function.ArgumentValidator.TooManyArgumentsException
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.SymbolAndFunctionCleaner
import testutil.TestUtilities.evaluateString
@TestInstance(PER_CLASS)
@LispTestInstance
class ExitTest : SymbolAndFunctionCleaner() {
companion object {

View File

@ -4,14 +4,14 @@ import function.ArgumentValidator.BadArgumentTypeException
import function.ArgumentValidator.TooFewArgumentsException
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.SymbolAndFunctionCleaner
import testutil.TestUtilities.evaluateString
import testutil.TypeAssertions.assertNil
import testutil.TypeAssertions.assertT
@TestInstance(PER_CLASS)
@LispTestInstance
class NumericEqualTest : SymbolAndFunctionCleaner() {
@Test

View File

@ -6,13 +6,13 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.TestUtilities.createInputStreamFromString
import java.io.ByteArrayOutputStream
import java.io.PrintStream
@TestInstance(PER_CLASS)
@LispTestInstance
class LispInterpreterTest {
companion object {

View File

@ -5,10 +5,9 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Assertions.fail
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import scanner.LispScanner.UnterminatedStringException
import stream.LispIOException
import testutil.LispTestInstance
import testutil.TestUtilities.assertIsErrorWithMessage
import testutil.TestUtilities.createIOExceptionThrowingInputStream
import testutil.TestUtilities.createInputStreamFromString
@ -24,7 +23,7 @@ import token.Eof.EofEncounteredException
import token.RightParenthesis.StartsWithRightParenthesisException
import token.TokenFactory.BadCharacterException
@TestInstance(PER_CLASS)
@LispTestInstance
class LispParserTest {
private fun createLispParser(input: String) = LispParser(createInputStreamFromString(input), "testFile")

View File

@ -2,11 +2,10 @@ package recursion
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import recursion.TailCalls.done
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class TailCallTest {
@Test

View File

@ -4,14 +4,13 @@ import error.Severity.CRITICAL
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import scanner.LispInputStream.MaximumUnreadsExceededException
import stream.LispIOException
import testutil.LispTestInstance
import testutil.TestUtilities.createIOExceptionThrowingInputStream
import testutil.TestUtilities.createInputStreamFromString
@TestInstance(PER_CLASS)
@LispTestInstance
class LispCommentRemovingInputStreamTest {
private fun getLispCommentRemovingInputStreamResult(inputString: String) =

View File

@ -3,11 +3,11 @@ package scanner
import file.FilePosition
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.TestUtilities.createInputStreamFromString
@TestInstance(PER_CLASS)
@LispTestInstance
class LispScannerLineColumnTest {
companion object {

View File

@ -2,11 +2,11 @@ package scanner
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.TestUtilities.createInputStreamFromString
@TestInstance(PER_CLASS)
@LispTestInstance
class LispScannerTextTest {
private fun assertTokenTextMatches(input: String, expectedText: Array<String>) {

View File

@ -4,9 +4,8 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import scanner.LispScanner.UnterminatedStringException
import testutil.LispTestInstance
import testutil.TestUtilities.assertIsErrorWithMessage
import testutil.TestUtilities.createInputStreamFromString
import token.AtSign
@ -22,7 +21,7 @@ import token.RightParenthesis
import token.Token
import token.TokenFactory.BadCharacterException
@TestInstance(PER_CLASS)
@LispTestInstance
class LispScannerTypeTest {
private val expectedTypes = mutableListOf<Class<out Token>>()

View File

@ -4,16 +4,15 @@ import function.UserDefinedFunction
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.LispNumber.InvalidNumberException
import testutil.LispTestInstance
import testutil.TestUtilities.assertIsErrorWithMessage
import testutil.TestUtilities.assertSExpressionsMatch
import testutil.TestUtilities.makeList
import java.math.BigInteger
import java.util.Locale
@TestInstance(PER_CLASS)
@LispTestInstance
class SExpressionTest {
private fun assertSExpressionMatchesString(expected: String, sExpression: SExpression) {

View File

@ -4,13 +4,12 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.TestUtilities.createIOExceptionThrowingInputStream
import testutil.TestUtilities.createInputStreamFromString
import util.Characters.EOF
@TestInstance(PER_CLASS)
@LispTestInstance
class SafeInputStreamTest {
private lateinit var safe: SafeInputStream

View File

@ -4,12 +4,11 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import testutil.TestUtilities.createIOExceptionThrowingOutputStream
import java.io.ByteArrayOutputStream
@TestInstance(PER_CLASS)
@LispTestInstance
class SafeOutputStreamTest {
private lateinit var safe: SafeOutputStream

View File

@ -4,13 +4,12 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Nil
import sexpression.Symbol.Companion.T
import table.SymbolTable.NullSymbolTable
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class ExecutionContextTest {
@BeforeEach

View File

@ -8,8 +8,6 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Cons
import sexpression.LispString
import sexpression.Nil
@ -19,8 +17,9 @@ import table.FunctionTable.defineFunction
import table.FunctionTable.isAlreadyDefined
import table.FunctionTable.lookupFunction
import table.FunctionTable.resetFunctionTable
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class FunctionTableTest {
@FunctionNames("GOOD")

View File

@ -3,12 +3,11 @@ package table
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import sexpression.Nil
import sexpression.Symbol.Companion.T
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class SymbolTableTest {
private lateinit var symbolTable: SymbolTable

View File

@ -3,8 +3,6 @@ package terminal
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import stream.SafeInputStream
import terminal.ControlSequence.NullControlSequence
import terminal.ControlSequenceHandler.Companion.isEscape
@ -13,10 +11,11 @@ import terminal.SelectGraphicRendition.PURPLE
import terminal.SelectGraphicRendition.RED
import terminal.SelectGraphicRendition.RESET
import terminal.SelectGraphicRendition.YELLOW
import testutil.LispTestInstance
import testutil.TestUtilities
import util.Characters.EOF
@TestInstance(PER_CLASS)
@LispTestInstance
class ControlSequenceHandlerTest {
private lateinit var handler: ControlSequenceHandler

View File

@ -6,17 +6,16 @@ import com.googlecode.lanterna.terminal.virtual.VirtualTerminal
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import terminal.ControlSequence.NullControlSequence
import terminal.SelectGraphicRendition.GREEN
import terminal.SelectGraphicRendition.PURPLE
import terminal.SelectGraphicRendition.RED
import terminal.SelectGraphicRendition.RESET
import terminal.SelectGraphicRendition.YELLOW
import testutil.LispTestInstance
import java.util.HashSet
@TestInstance(PER_CLASS)
@LispTestInstance
class ControlSequenceTest {
private lateinit var indicatorSet: MutableSet<String>

View File

@ -11,11 +11,10 @@ import com.googlecode.lanterna.input.KeyType.Escape
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import terminal.LispTerminal.Companion.END_OF_SEGMENT
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class LispTerminalTest {
private lateinit var terminal: VirtualTerminalInteractor

View File

@ -3,14 +3,13 @@ package terminal
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import stream.LispIOException
import testutil.LispTestInstance
import java.io.IOException
import java.io.PipedInputStream
import java.io.PipedOutputStream
@TestInstance(PER_CLASS)
@LispTestInstance
class TerminalConfigurationTest {
private lateinit var configuration: TerminalConfiguration

View File

@ -4,10 +4,9 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
@TestInstance(PER_CLASS)
@LispTestInstance
class TerminalHistoryTest {
private lateinit var history: TerminalHistory

View File

@ -0,0 +1,9 @@
package testutil
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import kotlin.annotation.AnnotationTarget.CLASS
@Target(CLASS)
@TestInstance(PER_CLASS)
annotation class LispTestInstance

View File

@ -6,12 +6,12 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import testutil.LispTestInstance
import token.TokenFactory.BadCharacterException
import token.TokenFactory.EmptyTokenTextException
@TestInstance(PER_CLASS)
@LispTestInstance
class TokenFactoryTest {
private lateinit var tokenFactory: TokenFactory
@ -80,7 +80,7 @@ class TokenFactoryTest {
try {
createToken("")
} catch (e: EmptyTokenTextException) {
assertThat(e.message).isNotEmpty();
assertThat(e.message).isNotEmpty()
assertThat(e.severity).isEqualTo(CRITICAL)
}
}