07 Laboratory Exercise 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Ballesteros, Mark Andrei J.

BSIT 501

1. Create a folder on your local drive with your name. (Ex. Jess_Diaz)
2. Open NetBeans IDE 8.2. Go to File > New Project. The New Project dialog box will appear. Select
Java in Categories > Java Application in Projects. Then, click the Next button.
3. Write TaxCalculator in Project Name and check the Use Dedicated Folder for Storing Libraries option.
Click Finish to create the project.

4. Go to File > New File. The New File dialog box will appear. Select Java in Categories > Java Class in
File Types. Then, click the Next button.
5. Write ItemTaxCalculator in Class Name and select taxcalculator in Package. Click Finish to create the
new class.
6. Write the following program in the ItemTaxCalculator class. The CalculateItemTax method will be
used to calculate an item sales tax.

7. Write a unit test using the JUnit unit testing tool available for NetBeans IDE. This unit test will be used
to test the CalculateItemTax method.
8. Go to File > New File. The New File dialog box will appear. Select Unit Tests in Categories > Junit
Test in File Types. Then, click the Next button.
9. Write ItemTaxCalculatorTest in the Class name and write the package name taxcalculator in Package.
Tick all the checkbox options in Generated Code and Generated Comments. Click Finish to create the unit
test class and the Test Packages node.

10. Go to the Projects directory to view the project. Your project directory for the current project should
be the same as Figure 1.
11. To execute a test, go to Projects. Right-click the class file to test, which is the ItemTaxCalculator, then
select Test File. This will run a test to the project but will result to Failed (see Figure 2). This is because
there are no runnable test methods found in the test class.

12. To create a test method in the test class, write the following test method inside the
ItemTaxCalculatorTest class:

13. Run the Test File again to run the unit test. This should result to Passed (see Figure 3).
Activity:
1. Using NetBeans IDE, extract and open the java zipped project LoginModule in 07 Software System for
Testing folder. This project contains functions that allow users to log in to and create an account for the
system . This also has functions that will compute basic salary based on hourly rate, hours worked, and
overtime.
2. Create unit tests for the following classes of the system that will result all into “passed”:
• VerifyUserLogin

• PayrollCalculator

You might also like