I just complete a Java CONSOLE application for Student Management.
I received a test case set (pdf file contains lines follow according to the requirements of the application) build based on the standard program (from my lecturer) . You can overview what my app do and what is format of test casenter image description heree set in the attached image below.
The problem is that I want to use test cases for testing my app but instead of manually entering and matching line by line between Console IO and the pdf file => I want to write a program to automatically import and match the data between my jar/program to test cases .
However, I’m not sure how and where to start. I have tried with google but unit test/white testing is still the thing that takes up all of my search. Hopefully in the process of continuing to try to search with google, someone will give me some suggestions or directions that will be useful to me. Thanks very much.
[Test cases set]
This sounds like you are looking for advice on how to do an actual paid job, but generically (when talking about testing this sort of thing in Java) I would still recommend leveraging JUnit. I would first try to convert the PDF file into something more readily consumed by a program, for example a CSV file, JSON, protobuf, or even XML.
Then, you would be able to read the file (perhaps using something like
java.nio.file.Files) and execute the instructions. For testability, it may mean setting up some dependency injection so that your console application can get its input from a generic
InputStream that you set to
System.in for your main program and to your custom
InputStream for the test. Depending on how you want to structure your test inputs, you could also make the test cases into a number of files where each file has its own input and expected output file that you use to write the tests (which could allow you to use
Files.newInputStream on the input file).