Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:39:02+00:00 2026-06-16T09:39:02+00:00

These tests should run after the jar file is built. They should test whether

  • 0

These tests should run after the jar file is built.
They should test whether it runs at all,
and whether it produces correct console output given certain input files.

Could you point at some examples of such tests for console applications? Do these test have to be written in Java to be used with Maven?

There is a similar question (Testing console based applications/programs – Java) but what I need is blackbox testing, not unit testing. And it does not mention Maven.


UPDATE:

It turned out that it vas very easy to do. My first problem was a misconception of integration tests after seeing so many definitions here (What is Unit test, Integration Test, Smoke test, Regression Test?; What's the difference between unit, functional, acceptance, and integration tests?; What are unit testing and integration testing, and what other types of testing should I know about?; What is an integration test exactly?). The second problem was that I did not intend to write these test in Java, but in the end I had to learn how to use java.lang.Runtime.

First of all, I have added this to my pom.xml:

<plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Then I have created an *IT.java file in src/test/java:

public class MyAppIT {

    @Test
    public void test() throws IOException {
        Runtime runtime = Runtime.getRuntime();
        String cmd = "java -cp target/myapp.jar my.app.Main";
        Process process = runtime.exec(cmd);
        InputStreamReader isr = new InputStreamReader(process.getErrorStream());
        BufferedReader br = new BufferedReader(isr);
        Boolean containsUsage = false;
        String line;
        while ((line = br.readLine()) != null) {
            if (line.contains("Usage")) {
                containsUsage = true;
            }
        }
        assertTrue(containsUsage);
    }
}

Now I use mvn verify instead of mvn package.

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:39:04+00:00Added an answer on June 16, 2026 at 9:39 am

    It seems you want integration testing.

    In many cases, the application is built by a continuous integration (CI) system like Hudson, Travis or sth. This CI compiles and runs the unit-tests after each commit to the sourcecode.
    After successful compilation, the integration-test projects are triggered.

    The integration-tests reside in a separate maven source project. You would create the integration-test-classes like normal unit tests in src/test/java. Of course you don’t test a single class in isolation – that is unit testing – you setup your system for integration-tests (wire the right components) and execute the needed tests “smoke test”.

    So, in your case, you could create another project for integration-test and execute this after the build of your application. You could create a maven parent-pom and use sub-modules to avoid the manual integration-test-build.

    The test classes need to be java and located in src/test/java, they look like normal unit tests and are run by maven.
    Of course you could start a non-java program in that tests and assert the outcome.

    A console app has a “main” method, so I would call the main method in the test. Otherwise you have to run a shell command or something. (via java.lang.Runtime)

    There is no speciality in testing console apps. Unless you want to test the user interface – automated testing of user interfaces is not easy and more difficult, please clarify if this is your focus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to automatically run tests, when a file in the app
After each commit into 'trunk', we automatically run a bunch of tests against trunk.
When I run my unit tests in isolation they work fine ie. (omitted the
After I have set up all the unit test cases for my android application
I have a few Silverlight UI tests that I'm automating with White. These tests
I can't seem to get these Rspec tests to pass. I just don't know
I'd like to write some tests for delete() in Grails. These need to be
I think its common for database tests to include CRUD operations. So these functions
We noticed that when testNG test cases extend TestCase (JUnit) those tests start executing
I have tables like these two test_table date student test 2012-05-31 Alice Math 2012-05-31

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.