Web hosting asp - 134 CHAPTER 5 PERFORMANCE THROUGH THE APPLICATION

134 CHAPTER 5 PERFORMANCE THROUGH THE APPLICATION DEVELOPMENT LIFE CYCLE JUnit offers the following benefits to your unit testing: Faster coding: How many times have you written debug code inside your classes to verify values or test functionality? JUnit eliminates this by allowing you to write test cases in closely related, but centralized and external, classes. Simplicity: If you have to spend too much time implementing your test cases, then you won t do it. Therefore, the creators of JUnit made it as simple as possible. Single result reports: Rather than generating loads of reports, JUnit will give you a single pass/fail result, and, for any failure, show you the exact point where the application failed. Hierarchical testing structure: Test cases exercise specific functionality, and test suites execute multiple test cases. JUnit supports test suites of test suites, so when developers build test cases for their classes, they can easily assemble them into a test suite at the package level, and then incorporate that into parent packages and so forth. The result is that a single, top-level test execution can exercise hundreds of unit test cases. Developer-written tests: These tests are written by the same person who wrote the code, so the tests accurately target the intricacies of the code that the developer knows can be problematic. This test differs from a QA-written one, which exercises the external functionality of the component or use case instead, this test exercises the internal functionality. Seamless integration: Tests are written in Java, which makes the integration of test cases and code seamless. Free: JUnit is open source and licensed under the Common Public License Version 1.0, so you are free to use it in your applications. From an architectural perspective, JUnit can be described by looking at two primary components: TestCaseand TestSuite. All code that tests the functionality of your class or classes must extend junit.framework.TestCase. The test class can implement one or more tests by defining public void methods that start with test and accept no parameters, for example: public void testMyFunctionality() { … } For multiple tests, 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 eliminate side effects between test cases; this makes each test case truly independent. Inside each TestCase test method, you can create objects, execute functionality, 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 provides to validate actual values against expected values is a set of assert methods: assertEquals() methods test primitive types. assertTrue() and assertFalse() test Boolean values. assertNull() and assertNotNull() test whether or not an object is null. assertSame() and assertNotSame() test object equality.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision best web hosting services

Leave a Reply