0

I have a program that receives command line arguments (in my case, it's a Scala program that uses Argot). A simplified use case would be something like:

sbt "run -n 300 -n 50"

And imagine that the app should only accept (and print) numbers between 0 and 100, meaning it should discard 300 and print only 50.

What's the best approach to test it? Is unit testing appropriated? Instead of processing the arguments in the main maybe I should refactor a function and test the function?

1
  • 5
    Factor it out and unit test the individual components. Commented Jul 19, 2015 at 2:05

1 Answer 1

1

If you want to test the very act of passing arguments to your program then you'll be required to perform a blackbox integration/system test (not an unit test):

Black-box testing is a method of software testing that examines the functionality of an application without peering into its internal structures or workings. See this.

Otherwise, do as Chris said and factor out the code to test the underlying logic without testing the act of receiving an argument.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.