Professional Documents
Culture Documents
JUNIT
Testing
Testing
Agile Testing:
Agile testingis asoftware testingpractice that follows
1st Principle
Agile teams test continuously. Its the only
2nd Principle
3rd Principle
4th Principle
5th Principle
6th Principle
7th Principle
8th Principle
9th Principle
Agile Methodologies
SCRUM
XP(Extreme Programming)
DSDM (Dynamic Systems Development
Method)
Extreme Programming
The
Simplicity.
Choose a system metaphor.
Use CRC cards for design sessions.
Create spike solutions to reduce risk.
No functionality is added early.
Refactor whenever and wherever possible.
Managing
Coding
The customer is always available.
Code must be written to agreed standards.
Code the unit test first.
All production code is pair programmed.
Only one pair integrates code at a time.
Integrate often.
Set up a dedicated integration computer.
Use collective ownership.
Testing
All code must have unit tests.
All code must pass all unit tests before it can be released.
When a bug is found tests are created.
Acceptance tests are run often and the score
is published.
JUNIT
JUnit is aRegression Testing Frameworkused by
Fixtures:
Fixturesis a fixed state of a set of objects
Test Suites:
Test suitemeans bundle a few unit test
Test Runner
Test runneris used for executing the test
Junit Classes
JUnit classesare important classes which is
Assertions
JUnit provides static methods in the Assert
class
test class
test suite class (optional)
runner class
Point to note:
Add annotation @Test before writing the test.
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestJunit {
String message = "Hello World";
MessageUtil messageUtil = new MessageUtil(message);
@Test
public void testPrintMessage() {
assertEquals(message,messageUtil.printMessage());
}
}
Question
Write down the Junit test cases , test suites
writing tests before writing code and make the test fail.
In this, write enough code so that test can pass and then
at last refactor the code as per you requirement and
make sure the test is passing again after the change.
Now, the main focus of TDD will be on testing the lowlevel functionality and units (for single classes and
methods) that can lead to more flexible code and easier
refactoring.
In a simple language we can say,we write these tests
to check if the code we wrote works fine.
Tools
TDD
ATDD
BDD
Junit
Fitnesse
JBehave
cpputest
Spectacular
Lettuce
GoogleTest
Concordion
Easyb
DBFit
Thucydides
SpecFlow