Unit Testing

  1. Types of testing
    • Black box testing
    • Gray box testing
    • White box testing
    • Unit testing
    • Integration testing
    • System testing
    • Acceptance testing
  2. What is black box testing
    • Testing of a system without understanding it's implementation
    • Testing based on requirements
  3. Black box testing techniques
    • Robustness testing
    • Ad hoc/exploratory testing
    • Equivalence partitioning
    • Boundary value analysis
  4. Black box: Equivalence partitioning
    Reduces number of test cases by selecting the right test cases for all possible scenarios
  5. Black box: Boundary value analysis
    • Choose test cases as boundaries of equivalence partitions
    • Handles one-off errors
  6. Black box: Robustness testing
    Test values outside of domain
  7. How are boundary testing and equivalence classes related
    • Equivalence class are the valid sets of input data
    • Boundary testing tests the boundaries of equivalence classes
  8. Most common use for gray box testing
    Web applications due to their distributed nature
  9. Gray box testing
    Testing of functionality, but also looking at how it is done to make sure that is correct also
  10. Examples of gray box testing
    • Application cleans up temporary files
    • Network or database connections are closed
    • Memory usage is steady (no leaks)
    • Very that transitions are properly logged
    • Data formats are correct
  11. What is unit testing
    Validating each individual unit of source code is working properly
  12. Goal of unit testing
    Show that individual units are correct
  13. What is a "unit" in unit testing?
    Smallest possible testable item
  14. Types of programming that can be used with unit testing
    • Procedural
    • Object oriented
  15. How can procedural programs be tested?
    Test functions, procedures and subroutines
  16. How can object oriented programs be tested?
    Test methods (usually public)
  17. Test fixture
    • Class containing one or more test methods
    • Used in xunit and gtest
  18. Test method
    Method that executes a specific test
  19. Test runner (xunit)
    Application that finds and executes test methods
  20. Assertion
    Boolean expressions that describe what must be true when an action executes
  21. Common GTest macros
    • RUN_ALL_TEST()
    • TEST(Suite, Test)
    • TEST_F(Suit, Test) <- If an object is used

    Various assertions
  22. GTest assertions
    • ASSERT_TRUE(expected, actual)
    • ASSERT_EQ(expected, actual)
    • ASSERT_LT(expected, actual) <- Less than
    • ASSERT_THROW(method, exception)
    • ASSERT_DOUBLE_EQ(expected, actual)
    • Replace assert for EXPECT if continued testing is desired
  23. How is TEST different from TEST_F in  GTest?
    • TEST is run independent of other tests
    • TEST_F uses a common data object
  24. (GTest) What is the macro to initiate testing? Where is it called?
    • RUN_ALL_TESTS() Include gtest library
    • Call macro in test main
  25. GTest main file declaration (only show one line)
    int main (int argc, char **argv) {
Author
Ant
ID
353590
Card Set
Unit Testing
Description
unit
Updated