Refactor test code
This commit is contained in:
		
							parent
							
								
									daf43b0ea7
								
							
						
					
					
						commit
						1b14306a99
					
				@ -19,11 +19,11 @@ class RuntimeEnvironmentTest {
 | 
			
		||||
        private const val TERMINATED_EXCEPTIONALLY = "TERMINATED_EXCEPTIONALLY"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private var indicatorSet: MutableSet<String>? = null
 | 
			
		||||
    private val indicatorSet: MutableSet<String> = HashSet()
 | 
			
		||||
 | 
			
		||||
    @BeforeEach
 | 
			
		||||
    fun setUp() {
 | 
			
		||||
        indicatorSet = HashSet()
 | 
			
		||||
        indicatorSet.clear()
 | 
			
		||||
        RuntimeEnvironment.reset()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -77,18 +77,18 @@ class RuntimeEnvironmentTest {
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    fun `assign a termination function`() {
 | 
			
		||||
        RuntimeEnvironment.terminationFunction = Runnable { indicatorSet!!.add(TERMINATED_SUCCESSFULLY) }
 | 
			
		||||
        RuntimeEnvironment.terminationFunction = Runnable { indicatorSet.add(TERMINATED_SUCCESSFULLY) }
 | 
			
		||||
        RuntimeEnvironment.terminateSuccessfully()
 | 
			
		||||
 | 
			
		||||
        assertThat(indicatorSet!!.contains(TERMINATED_SUCCESSFULLY)).isTrue()
 | 
			
		||||
        assertThat(indicatorSet.contains(TERMINATED_SUCCESSFULLY)).isTrue()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    fun `assign an error termination function`() {
 | 
			
		||||
        RuntimeEnvironment.errorTerminationFunction = Runnable { indicatorSet!!.add(TERMINATED_EXCEPTIONALLY) }
 | 
			
		||||
        RuntimeEnvironment.errorTerminationFunction = Runnable { indicatorSet.add(TERMINATED_EXCEPTIONALLY) }
 | 
			
		||||
        RuntimeEnvironment.terminateExceptionally()
 | 
			
		||||
 | 
			
		||||
        assertThat(indicatorSet!!.contains(TERMINATED_EXCEPTIONALLY)).isTrue()
 | 
			
		||||
        assertThat(indicatorSet.contains(TERMINATED_EXCEPTIONALLY)).isTrue()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
@ -134,8 +134,8 @@ class RuntimeEnvironmentTest {
 | 
			
		||||
        RuntimeEnvironment.errorOutput = System.err
 | 
			
		||||
        RuntimeEnvironment.errorManager = ErrorManager()
 | 
			
		||||
        RuntimeEnvironment.path = "testpath/"
 | 
			
		||||
        RuntimeEnvironment.terminationFunction = Runnable { indicatorSet!!.add(TERMINATED_SUCCESSFULLY) }
 | 
			
		||||
        RuntimeEnvironment.errorTerminationFunction = Runnable { indicatorSet!!.add(TERMINATED_EXCEPTIONALLY) }
 | 
			
		||||
        RuntimeEnvironment.terminationFunction = Runnable { indicatorSet.add(TERMINATED_SUCCESSFULLY) }
 | 
			
		||||
        RuntimeEnvironment.errorTerminationFunction = Runnable { indicatorSet.add(TERMINATED_EXCEPTIONALLY) }
 | 
			
		||||
        RuntimeEnvironment.promptDecorator = Function { s -> "[$s]" }
 | 
			
		||||
        RuntimeEnvironment.valueOutputDecorator = Function { s -> "($s)" }
 | 
			
		||||
        RuntimeEnvironment.warningOutputDecorator = Function { s -> "|$s|" }
 | 
			
		||||
 | 
			
		||||
@ -20,9 +20,9 @@ class ErrorManagerTest {
 | 
			
		||||
        private const val MESSAGE = "message"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private lateinit var indicatorSet: MutableSet<String>
 | 
			
		||||
    private lateinit var errorOutputStream: ByteArrayOutputStream
 | 
			
		||||
    private lateinit var outputStream: ByteArrayOutputStream
 | 
			
		||||
    private val indicatorSet: MutableSet<String> = HashSet()
 | 
			
		||||
    private val errorOutputStream: ByteArrayOutputStream = ByteArrayOutputStream()
 | 
			
		||||
    private val outputStream: ByteArrayOutputStream = ByteArrayOutputStream()
 | 
			
		||||
 | 
			
		||||
    private fun createErrorManagerWithIndicators(): ErrorManager {
 | 
			
		||||
        RuntimeEnvironment.errorTerminationFunction = Runnable { indicatorSet.add(TERMINATED) }
 | 
			
		||||
@ -68,9 +68,9 @@ class ErrorManagerTest {
 | 
			
		||||
 | 
			
		||||
    @BeforeEach
 | 
			
		||||
    fun setUp() {
 | 
			
		||||
        indicatorSet = HashSet()
 | 
			
		||||
        errorOutputStream = ByteArrayOutputStream()
 | 
			
		||||
        outputStream = ByteArrayOutputStream()
 | 
			
		||||
        indicatorSet.clear()
 | 
			
		||||
        errorOutputStream.reset()
 | 
			
		||||
        outputStream.reset()
 | 
			
		||||
        RuntimeEnvironment.reset()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user