Skip to content

drop-project-edu/stdin-stdout-junit-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stdin/Stdout Helper for JUnit

Useful for testing java/kotlin programs interaction with the command line.

How to install

Include the following dependency on your pom file:

<dependency>
    <groupId>pt.ulusofona.deisi</groupId>
    <artifactId>stdin-stdout-junit-helper</artifactId>
    <version>0.2.0</version>
</dependency>

How to use

class TestStdinStdout {

    @Test
    public void testAskName() {
        StdinStdoutHelper helper = new StdinStdoutHelper()
                .expectOutput("Enter your name")
                .simulateInput("Pedro")
                .expectOutput("Your name is Pedro");

        helper.start();
        main(null);
        helper.stop();
    }
}