Advanced Unit Testing MCQs

  1. Which JUnit annotation is used for parameterized tests?
    a) @ParameterizedTest
    b) @ParamTest
    c) @TestCase
    d) @RunWith
    View Answer

    Correct answer: A — @ParameterizedTest

  2. In PyTest, parameterized tests are defined using:
    a) @pytest.mark.parametrize
    b) @pytest.parameter
    c) @pytest.args
    d) @pytest.values
    View Answer

    Correct answer: A — @pytest.mark.parametrize

  3. NUnit supports parameterized tests using:
    a) [TestCase]
    b) [Param]
    c) [Args]
    d) [Values]
    View Answer

    Correct answer: A — [TestCase]

  4. Which JUnit annotation runs once before all tests in a class?
    a) @BeforeClass
    b) @Before
    c) @Init
    d) @Setup
    View Answer

    Correct answer: A — @BeforeClass

  5. Which JUnit annotation runs once after all tests in a class?
    a) @AfterClass
    b) @After
    c) @Cleanup
    d) @End
    View Answer

    Correct answer: A — @AfterClass

  6. PyTest fixtures can have which scope?
    a) function, class, module, session
    b) test, suite, package, run
    c) local, global, static, dynamic
    d) init, setup, teardown, cleanup
    View Answer

    Correct answer: A — function, class, module, session

  7. NUnit supports setup methods using:
    a) [SetUp]
    b) [Init]
    c) [Before]
    d) [Start]
    View Answer

    Correct answer: A — [SetUp]

  8. Which JUnit assertion checks if two objects are the same?
    a) assertSame
    b) assertEquals
    c) assertTrue
    d) assertNull
    View Answer

    Correct answer: A — assertSame

  9. PyTest supports skipping tests conditionally using:
    a) @pytest.mark.skipif
    b) @pytest.skip
    c) @pytest.ignore
    d) @pytest.stop
    View Answer

    Correct answer: A — @pytest.mark.skipif

  10. NUnit supports ignoring tests with reason using:
    a) [Ignore("reason")]
    b) [Skip("reason")]
    c) [Disable("reason")]
    d) [Stop("reason")]
    View Answer

    Correct answer: A — [Ignore("reason")]

  11. What will be printed?
    1 import org.junit.jupiter.api.Test;
    2 import static org.junit.jupiter.api.Assertions.assertEquals;
    3 public class EduinqAdvancedTest {
    4 @Test
    5 void testAddition() {
    6 assertEquals(5, 2+3);
    7 System.out.println("Eduinq Advanced JUnit");
    8 }
    9 }
    a) Eduinq Advanced JUnit
    b) 5
    c) No output
    d) Compilation error
    View Answer

    Correct answer: A — Eduinq Advanced JUnit

  12. PyTest supports marking tests as expected to fail using:
    a) @pytest.mark.xfail
    b) @pytest.mark.fail
    c) @pytest.mark.error
    d) @pytest.mark.skip
    View Answer

    Correct answer: A — @pytest.mark.xfail

  13. NUnit supports test case sources using:
    a) [TestCaseSource]
    b) [CaseSource]
    c) [SourceTest]
    d) [DataCase]
    View Answer

    Correct answer: A — [TestCaseSource]

  14. JUnit supports exception testing using:
    a) assertThrows
    b) assertException
    c) assertError
    d) assertFail
    View Answer

    Correct answer: A — assertThrows

  15. PyTest supports running tests in parallel using:
    a) pytest-xdist
    b) pytest-parallel
    c) pytest-runner
    d) pytest-multi
    View Answer

    Correct answer: A — pytest-xdist

  16. NUnit supports running tests in parallel using:
    a) [Parallelizable]
    b) [Concurrent]
    c) [MultiThread]
    d) [Async]
    View Answer

    Correct answer: A — [Parallelizable]

  17. Which JUnit assertion checks if an object is not null?
    a) assertNotNull
    b) assertNull
    c) assertEmpty
    d) assertNone
    View Answer

    Correct answer: A — assertNotNull

  18. PyTest supports custom markers defined in:
    a) pytest.ini
    b) pytest.json
    c) pytest.yaml
    d) pytest.config
    View Answer

    Correct answer: A — pytest.ini

  19. NUnit supports teardown methods using:
    a) [TearDown]
    b) [Cleanup]
    c) [After]
    d) [End]
    View Answer

    Correct answer: A — [TearDown]

  20. JUnit supports grouping tests using:
    a) Test suites
    b) Test clusters
    c) Test packages
    d) Test groups
    View Answer

    Correct answer: A — Test suites

  21. PyTest supports fixtures with autouse option to:
    a) Run automatically without explicit reference
    b) Run only once
    c) Run only in session scope
    d) Run only in class scope
    View Answer

    Correct answer: A — Run automatically without explicit reference

  22. NUnit supports categories using:
    a) [Category]
    b) [Group]
    c) [Tag]
    d) [Suite]
    View Answer

    Correct answer: A — [Category]

  23. Which JUnit annotation disables a test?
    a) @Disabled
    b) @Ignore
    c) @Skip
    d) @Stop
    View Answer

    Correct answer: A — @Disabled

  24. PyTest supports fixtures with yield for:
    a) Setup and teardown in one function
    b) Logging
    c) Monitoring
    d) Deployment
    View Answer

    Correct answer: A — Setup and teardown in one function

  25. NUnit supports expected exceptions using:
    a) Assert.Throws
    b) Assert.Exception
    c) Assert.Error
    d) Assert.Fail
    View Answer

    Correct answer: A — Assert.Throws

  26. JUnit supports nested tests using:
    a) @Nested
    b) @Inner
    c) @Child
    d) @SubTest
    View Answer

    Correct answer: A — @Nested

  27. PyTest supports parameterized fixtures using:
    a) @pytest.fixture(params=[...])
    b) @pytest.parameter
    c) @pytest.args
    d) @pytest.values
    View Answer

    Correct answer: A — @pytest.fixture(params=[...])

  28. NUnit supports test case repetition using:
    a) [Repeat]
    b) [Loop]
    c) [Retry]
    d) [RunAgain]
    View Answer

    Correct answer: A — [Repeat]

  29. Which JUnit assertion checks if two arrays are equal?
    a) assertArrayEquals
    b) assertEquals
    c) assertSame
    d) assertTrue
    View Answer

    Correct answer: A — assertArrayEquals

  30. PyTest supports skipping tests dynamically using:
    a) pytest.skip()
    b) pytest.ignore()
    c) pytest.stop()
    d) pytest.fail()
    View Answer

    Correct answer: A — pytest.skip()

  31. NUnit supports constraints using:
    a) Assert.That
    b) Assert.Constraint
    c) Assert.Check
    d) Assert.Verify
    View Answer

    Correct answer: A — Assert.That

  32. JUnit supports timeout testing using:
    a) @Timeout
    b) @TimeLimit
    c) @Duration
    d) @Limit
    View Answer

    Correct answer: A — @Timeout

  33. PyTest supports fixtures with finalizer using:
    a) request.addfinalizer
    b) request.finalize
    c) request.cleanup
    d) request.teardown
    View Answer

    Correct answer: A — request.addfinalizer

  34. NUnit supports test case data using:
    a) [TestCaseData]
    b) [CaseData]
    c) [DataCase]
    d) [SourceData]
    View Answer

    Correct answer: A — [TestCaseData]

  35. Which JUnit assertion checks if a condition is false?
    a) assertFalse
    b) assertTrue
    c) assertEquals
    d) assertNull
    View Answer

    Correct answer: A — assertFalse

  36. PyTest supports marking tests with custom IDs using:
    a) ids parameter in parametrize
    b) id parameter in fixture
    c) id marker
    d) id option in pytest.ini
    View Answer

    Correct answer: A — ids parameter in parametrize

  37. NUnit supports multiple test cases using:
    a) [TestCase(...)]
    b) [Case(...)]
    c) [Param(...)]
    d) [Args(...)]
    View Answer

    Correct answer: A — [TestCase(...)]

  38. JUnit supports repeated tests using:
    a) @RepeatedTest
    b) @LoopTest
    c) @RetryTest
    d) @RunAgain
    View Answer

    Correct answer: A — @RepeatedTest

  39. PyTest supports marking tests with custom markers using:
    a) @pytest.mark.<marker>
    b) @pytest.marker.<marker>
    c) @pytest.tag.<marker>
    d) @pytest.case.<marker>
    View Answer

    Correct answer: A — @pytest.mark.<marker>

  40. NUnit supports timeout for tests using:
    a) [Timeout]
    b) [TimeLimit]
    c) [Duration]
    d) [Limit]
    View Answer

    Correct answer: A — [Timeout]

  41. Which JUnit assertion checks if two objects are not the same?
    a) assertNotSame
    b) assertSame
    c) assertEquals
    d) assertTrue
    View Answer

    Correct answer: A — assertNotSame

  42. PyTest supports marking tests with custom conditions using:
    a) @pytest.mark.condition
    b) @pytest.mark.skipif
    c) @pytest.mark.runif
    d) @pytest.mark.case
    View Answer

    Correct answer: B — @pytest.mark.skipif

  43. NUnit supports retrying failed tests using:
    a) [Retry]
    b) [Repeat]
    c) [Loop]
    d) [RunAgain]
    View Answer

    Correct answer: A — [Retry]

  44. Which JUnit annotation is used to provide display names for tests?
    a) @DisplayName
    b) @Name
    c) @Label
    d) @Title
    View Answer

    Correct answer: A — @DisplayName

  45. PyTest supports marking tests to run only on certain platforms using:
    a) @pytest.mark.skipif(sys.platform == ...)
    b) @pytest.mark.platform
    c) @pytest.mark.os
    d) @pytest.mark.env
    View Answer

    Correct answer: A — @pytest.mark.skipif(sys.platform == ...)

  46. NUnit supports combining multiple assertions using:
    a) Assert.Multiple
    b) Assert.Combine
    c) Assert.Group
    d) Assert.All
    View Answer

    Correct answer: A — Assert.Multiple

  47. Which JUnit annotation is used for repeated tests?
    a) @RepeatedTest
    b) @LoopTest
    c) @RetryTest
    d) @RunAgain
    View Answer

    Correct answer: A — @RepeatedTest

  48. PyTest supports dynamically skipping tests using:
    a) pytest.skip()
    b) pytest.ignore()
    c) pytest.stop()
    d) pytest.fail()
    View Answer

    Correct answer: A — pytest.skip()

  49. NUnit supports parameterized tests with multiple values using:
    a) [Values]
    b) [Params]
    c) [Args]
    d) [Cases]
    View Answer

    Correct answer: A — [Values]

  50. Which of the following best describes advanced unit testing?
    a) Using parameterized tests, fixtures, and lifecycle methods
    b) Only testing integration scenarios
    c) Only testing performance aspects
    d) Only testing security vulnerabilities
    View Answer

    Correct answer: A — Using parameterized tests, fixtures, and lifecycle methods

Quick Links to Explore