Active Topics Memberlist Calendar Search Help | |
Register Login |
One Stop Testing Forum : Types Of Software Testing @ OneStopTesting : Functional Testing @ OneStopTesting |
Topic: Functional Testing |
|
Author | Message |
Manoj
Newbie Joined: 23Feb2007 Online Status: Offline Posts: 1 |
Topic: Functional Testing Posted: 23Feb2007 at 4:07pm |
This section is dedicated to implementing testing frameworks for performing functional tests against your code. Unit Testing Using JUnitThe tool of choice in the Java software development industry for implementing Unit tests is JUnit. Before diving into the details of building a JUnit test, let's review what JUnit is and what benefits it provides. JUnit is a simple regression testing framework that enables you to write repeatable tests. Originally written by Erich Gamma and Kent Beck, it has been embraced by thousands of developers and has grown into a collection of unit testing frameworks for a plethora of technologies. JUnit.org hosts support information and links to the other JUnit derivations. JUnit presents the following benefits to your unit testing:
Now that you're fired up and ready to dive into JUnit (maybe I'm a little too excited, but you're going to have fun, I promise!), let's look at its architecture. The architecture of JUnit is really quite simple and can be described by two primary components: TestCase and TestSuite. All code that tests the functionality of your class or classes must extend junit.framework.TestCase. It can implement one or more tests by defining public void methods that start with test and accept no parameters, for example: public void testMyFunctionality() { ... } If there are multiple tests, then you have the option of initializing and cleaning up the environment before and between tests by implementing the following two methods: setUp() and tearDown(). In setUp() you initialize the environment and in teardown() you clean up the environment. Note that these methods are called between each test to ensure that there are no side effects between test cases; they are truly independent. Inside each TestCase "test" method, you can create objects, execute functionality, etc. and then test the return values of those functional elements against expected results. If the return values are not as expected then the test fails, otherwise it passes. The mechanism that JUnit employs to test actual values against expected values is a set of assert methods:
In addition, a fail() method (that you can call anywhere in your test case) can immediately mark a test as failing. Post Resume: Click here to Upload your Resume & Apply for Jobs |
|
IP Logged | |
Forum Jump |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
© Vyom Technosoft Pvt. Ltd. All Rights Reserved.