It is often helpful to allow your program to read test input from a file. To use a file for testing, you must add the file to your resources folder in your test directory. Let’s start by creating a test file that can be used with our calculator application. The file contains two columns of numbers. Each set of numbers will be used as input to our four calculator functions: addition, subtraction, multiplication and division.
- [Instructor] Maven makes adding resources really easy.…It is often helpful to allow your program…to retest input from a file.…To use a file for testing, you must add the file…to your Resources folder in your test directory.…Then we must update our code to read from the file…and I'm gonna add print line statements…to help with debugging to make sure…that everything is working as expected.…Okay, let's use the calculator application again.…Let's add a file that contains a series of numbers.…Each of those numbers will be read in,…and then we will use the calculator to add them,…multiply them, divide them and subtract them.…
Let's take a look at a sample file.…I already created a simple file called Numbers.txt…that has five sets of numbers, just random numbers.…Each row has two numbers, so for example,…the first row has 10 and five.…It'll add 10 to five and get 15, subtract and get five,…multiply and get 50, divide and get two.…Once you have your file created,…we need to make sure we put it in the right directory,…
- Downloading Maven
- Installing Maven
- Understanding the lifecycle and dependencies of Maven
- Working with the Project Object Model (POM)
- Defining project relationships
- Using Maven plugins
- Creating a sample project with Maven
- Writing tests in Maven
- Packaging your app
Skill Level Intermediate
Java: Database Integration with JDBCwith David Gassner2h 51m Intermediate
1. Get Started with Maven
2. Understand Maven
3. Project Object Model (POM)
4. Maven Plugins
5. Create a Project with Maven
6. Test with Maven
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.