Skip to content

oglimmer/unit-test-stdin-stdout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit testing a stdin / stdout based program

The class FakeApp implements a CLI program using stdin and stdout for all it's interaction with the user.

This is unit-tested via the code:

@Test
public void lineByLineTests() {

    try (TestCase testCase = TestCase.build()
            .input("add-user oli glimmer").expect("user added")
            .input("add-user heiner test").expect("user added")
            .input("list-users").expect("user:", "1,oli,glimmer", "2,heiner,test")
            .input("del-user 1").expect("user deleted")
            .input("list-users").expect("user:", "2,heiner,test")
            .input("quit")) {

        FakeApp.main(null);

    }
}

(as seen in class UnitTest).

If you think this isn't unit testing and more component or even end-to-end testing - fair enough.

About

A framework to unit / junit test a stdin stdout based program

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages