- Invade the Code π½
- Posts
- π Day 7 of #100DaysOfCode: Embracing JUnit Testing! π
π Day 7 of #100DaysOfCode: Embracing JUnit Testing! π
Hey Invaders π½
Today marks a significant milestone as I completed my Java Development Bootcamp and ventured into the exciting realm of JUnit Testing! ππ»
Learning Highlights:
Unit Testing Fundamentals: Explored the essence of unit testing and how it ensures the reliability of my code through isolated tests. π§ͺ
The F.I.R.S.T. Principle: Embraced the principles of Fast, Isolated/Independent, Repeatable, Self-validating, and Timely tests to write effective test cases. π
JUnit5 Setup: Successfully set up my project with Gradle and integrated JUnit5 to streamline my testing process. π οΈ
Arrange, Act, Assert: Mastered the AAA pattern to structure my tests seamlessly, ensuring clarity and effectiveness. π
New Endeavors with JUnit5:
Today, I embarked on writing my first JUnit test for the integerDivision
method in the Calculator class. Hereβs a sneak peek of my journey:
public class Calculator {
public int integerDivision(int dividend, int divisor){
return dividend/divisor;
}
}
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class CalculatorTest {
@Test
void integerDivision(){
//Arrange
Calculator calculator= new Calculator();
//Act
int result = calculator.integerDivision(4,2);
//Assert
assertEquals(2, result,
"Integer division did not produce expected
result");
}
}
The cool thing about assertEquals which I never knew is that you can add a message to it so if the test fails you have a customized message telling you why!
Next Steps:
I'm thrilled to delve deeper into JUnit Testing, refining my skills to create robust and reliable tests for my Java applications. π
π©βπ» Letβs Connect: Have you started your journey with JUnit Testing? Share your experiences and insights! Let's empower each other on this coding adventure. π¬π€
Excited to bridge this testing gap! π‘ Follow my journey on GitHub too!
#100DaysOfCode #JUnitTesting #JavaDevelopment #CodingJourney #TechCommunity #ContinuousLearning #GrowthMindset #SoftwareTesting
Reply