Skip to main content

Posts

Featured

IntelliJ IDEA for unit testing

Image: www.wikipedia.org
Please read the previous post if you haven't, Previous (Java Unit Testing with JUnit ).

We are performing the same test but using IDE. And download IntelliJ IDEA if you haven't.
For this unit testing, i have created new project, no libraries, no template.
Create new directory "test", right click on project > add > directory. Mark the directory as test sources root. Create Calculator class, the class is created as , right click on project > add > java class.
paste the code

public class Calculator{ // default values double p = 0.0; double t = 0.0; double r = 0.0; // constructor that updates the values public Calculator(double p, double t, double r){ this.p = p; this.t = t; this.r = r; } // method that calculates the interest public double calculateInterest(){ return p*t*r / 100; } } Create test class for Calculator, press alt & enter on class name > create…

Latest Posts

Java Unit Testing with JUnit

Hide your dual boot Grub

Create a WiFi Hotspot using CMD