File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,14 +8,17 @@ import java.io.*
88class MessagesTest {
99 @Test
1010 fun showMessage () {
11- // Mock output state; instead of output to terminal -> output to a data stream (byte array)
12- val streamOut = ByteArrayOutputStream ()
13- System .setOut(PrintStream (streamOut))
11+ mockStatic(Base ::class .java).use {
12+ mocked -> mocked.`when `<Boolean > { Base .isCommandLine() }.thenReturn(true )
1413
15- Messages .showMessage( " TestTile: " , " Hello World! " )
16- val testOutput
14+ val streamOut = ByteArrayOutputStream ( )
15+ System .setOut( PrintStream (streamOut))
1716
18- assertEquals()
17+ Messages .showMessage(" TestTitle" , " Hello World!" )
18+ val testOutput = streamOut.toString()
19+
20+ assertTrue(testOutput.contains(" TestTitle: Hello World!" ))
21+ }
1922 }
2023
2124 @Test
@@ -52,15 +55,15 @@ class MessagesTest {
5255 }
5356
5457 @Test
55- fun log () {
58+ fun testLog1 () {
5659 }
5760
5861 @Test
59- fun testLog () {
62+ fun testLog2 () {
6063 }
6164
6265 @Test
63- fun logf () {
66+ fun testLogF () {
6467 }
6568
6669 @Test
You can’t perform that action at this time.
0 commit comments