0
0
Testing Fundamentalstesting~10 mins

Test suite organization in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a test suite using unittest in Python.

Testing Fundamentals
import unittest

class MyTests(unittest.[1]):
    def test_example(self):
        self.assertEqual(1 + 1, 2)
Drag options to blanks, or click blank then click option'
ATestCase
BTestSuite
CTestRunner
DTestLoader
Attempts:
3 left
💡 Hint
Common Mistakes
Using TestSuite instead of TestCase for defining test classes.
2fill in blank
medium

Complete the code to add a test case to a test suite.

Testing Fundamentals
suite = unittest.TestSuite()
suite.addTest(MyTests('[1]'))
Drag options to blanks, or click blank then click option'
Arun
Bsetup
Ctest_example
DtearDown
Attempts:
3 left
💡 Hint
Common Mistakes
Using lifecycle methods like setup or tearDown instead of test methods.
3fill in blank
hard

Fix the error in the code to run the test suite using unittest.

Testing Fundamentals
runner = unittest.TextTestRunner()
runner.[1](suite)
Drag options to blanks, or click blank then click option'
Arun
Bexecute
CrunTests
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like runTests or execute.
4fill in blank
hard

Fill both blanks to create a test suite from multiple test cases.

Testing Fundamentals
loader = unittest.TestLoader()
suite = unittest.TestSuite([
    loader.[1](MyTests),
    loader.[2](OtherTests)
])
Drag options to blanks, or click blank then click option'
AmakeSuite
Bunittest.runSuite
Cunittest.createSuite
Dunittest.buildSuite
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like runSuite or buildSuite.
5fill in blank
hard

Fill all three blanks to filter and run tests with unittest.

Testing Fundamentals
loader = unittest.TestLoader()
suite = loader.[1]('test_example')
runner = unittest.TextTestRunner()
runner.[2](suite)

# To run only tests matching a pattern, use [3] method.
Drag options to blanks, or click blank then click option'
AloadTestsFromName
Brun
Cdiscover
DloadTestsFromTestCase
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing loadTestsFromTestCase with loadTestsFromName.
Using runTests instead of run.