Software Testing and Validation Overview

Slide Note
Embed
Share

In this comprehensive guide, we delve into various aspects of software testing, including JUnit testing, test cases, verdicts, and exception handling in JUnit. Explore examples, methods, and best practices to enhance your understanding of software testing and validation processes.


Uploaded on Sep 17, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. SWE SWE 434 SOFTWARE SOFTWARE TESTING 434 TESTING AND AND VALIDATION VALIDATION LAB3 LAB3 JUNIT JUNIT 1 SWE 434Lab

  2. LAB LAB AGENDA AGENDA More Examples and Practice 2 SWE 434Lab

  3. UNIT UNIT TESTING TESTING Required Input and Expected Output. Input Output Unit 3 SWE 434Lab

  4. TEST TEST CASE CASE VERDICT VERDICT A verdict is the declared result of executing a singletest. We can get the verdict after the assertion statement Pass: the test case achieved its intended purpose, andthe software under test performed asexpected. Fail: the test case achieved its intended purpose,but the software under test did not perform asexpected. Error: the test case did not achieve its intended purpose. Potential reasons: An unexpected event occurred during the testcase. The test case could not be set upproperly 4 SWE 434Lab

  5. JUNIT JUNIT METHODS METHODS assertArrayEquals() Test whether two arrays are equal to each other. In other words, if the two arrays contain the same number of elements, and if all the elements in the array are equalto each other. assertTrue() + assertFalse() The assertTrue() and assertFalse() methods tests asingle expression to see if its value is either true, orfalse. assertNull() + assertNotNull() The assertNull() and assertNotNull() methods test asingle variable to see if it is null or notnull 5 SWE 434Lab

  6. E EXAM XAMP PL LE E 6 SWE 434Lab

  7. EXCEPTION EXCEPTION IN IN JUNIT JUNIT Add parameter to @Test annotation, indicating that a particular class of exception is expected to occur during the test Useful for simple cases, but it has its limits: you can't test the value of the message in the exception, or the state of a domain object after the exception has been thrown. 7 SWE 434Lab

  8. EXCEPTION EXCEPTION IN IN JUNIT JUNIT Catch exception, and use fail( ) if not thrown: Try{ MethodToBeTested() fail( Message ) } Catch(ExceptionType E){ } 8 SWE 434Lab

  9. E EXAM XAMP PL LE E 9 SWE 434Lab

  10. SETUP AND SETUP AND TEARDOWN For a collection of tests for a particular class, there are often some repeated tasks that must be done prior to each test case or after the end of each use cases: Set up connection Database Clean up Reset data TEARDOWN Ensures resources are released, test system is in known state for next test case, etc. Since a test case failure ends execution of a test method at that point, code to clean up cannot be at the end of the method. 10 SWE 434Lab

  11. SETUP AND SETUP AND TEARDOWN TEARDOWN Setup: Use the @Before annotation on a method containing codeto run before each test case. Teardown: Use the @After annotation on a method containing code to run after each test case. These methods will run even if exceptions are thrown inthe test case or an assertionfails. 11 SWE 434Lab

  12. SETUP AND SETUP AND TEARDOWN TEARDOWN ONCE ONCE Setup Once: Use the @BeforeClass to run a method once only for the entire test class, before any of the tests are executed, and prior to any @Before method(s) Teardown Once: Use the @AfterClass annotation to run after all test case methods in the class have been executed, and after any @After methods Useful for starting servers, opening communications, etc. that are time-consuming to close and re-open for each test. 12 SWE 434Lab

  13. SETUP AND SETUP AND TEARDOWN TEARDOWN 13 SWE 434Lab

Related


More Related Content