Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 4 MCQsVarious Testing Frameworks Available in Java
Which criterion helps determine whether a testing tool is practical for a team?
Not quite. Try another option.
Answer: Learning curve
The learning curve indicates how easily team members can learn and use the tool.
Question 3 of 60 · Fundamentals of Jenkins · Easy
What is Jenkins mainly used for?
Not quite. Try another option.
Answer: Continuous integration
Jenkins automates activities such as building software and running tests whenever changes are made.
Question 4 of 60 · Fundamentals of Jenkins · Easy
What can Jenkins automatically do after code is committed?
Not quite. Try another option.
Answer: Build and test the code
Jenkins can trigger automated builds and tests in response to source-code changes.
Question 5 of 60 · TestNG · Easy
What is TestNG?
Not quite. Try another option.
Answer: A Java testing framework
TestNG is a testing framework for Java that supports test organization and execution.
Question 6 of 60 · TestNG · Easy
Which annotation commonly identifies a test method in TestNG?
Not quite. Try another option.
Answer: @Test
TestNG uses the @Test annotation to mark a method as a test method.
Question 7 of 60 · Maven · Easy
What is Maven primarily used for in a Java project?
Not quite. Try another option.
Answer: Project building and dependency management
Maven manages project builds, dependencies, plugins, and other project information.
Question 8 of 60 · Maven · Easy
Which file commonly contains Maven project configuration?
Not quite. Try another option.
Answer: pom.xml
The pom.xml file, called the Project Object Model file, defines Maven project settings and dependencies.
Question 9 of 60 · JUnit 5 · Easy
Which annotation is used in JUnit 5 to mark a test method?
Not quite. Try another option.
Answer: @Test
JUnit 5 uses the @Test annotation from the org.junit.jupiter.api package.
Question 10 of 60 · JUnit 5 · Easy
Which component is the programming model used by JUnit 5?
Not quite. Try another option.
Answer: JUnit Jupiter
JUnit Jupiter provides the programming model and extension model for writing JUnit 5 tests.
Question 11 of 60 · Gherkin · Easy
What is Gherkin mainly used to write?
Not quite. Try another option.
Answer: Behavior descriptions
Gherkin is a readable language used to describe software behavior in structured scenarios.
Question 12 of 60 · Gherkin · Easy
Which Gherkin keyword usually describes an initial condition?
Not quite. Try another option.
Answer: Given
Given describes the initial context or precondition of a scenario.
Question 13 of 60 · Introduction to JUnit Framework · Easy
What is JUnit?
Not quite. Try another option.
Answer: A unit-testing framework for Java
JUnit is a popular framework for writing and running automated unit tests in Java.
Question 14 of 60 · Introduction to JUnit Framework · Easy
What is the main purpose of a unit test?
Not quite. Try another option.
Answer: To test a small unit of code
A unit test checks the behavior of a small, isolated part of a program, such as a method.
Question 15 of 60 · Define a Test in JUnit · Easy
Which annotation defines a test method in a JUnit test class?
Not quite. Try another option.
Answer: @Test
Adding @Test tells JUnit that the annotated method should be executed as a test.
Question 16 of 60 · JUnit Naming Conventions · Easy
Which is a commonly recommended name for a JUnit test method?
Not quite. Try another option.
Answer: shouldAddTwoNumbers
Descriptive names such as shouldAddTwoNumbers clearly communicate the behavior being tested.
Question 17 of 60 · JUnit Test Suites · Easy
What is the purpose of a JUnit test suite?
Not quite. Try another option.
Answer: To group tests for execution
A test suite organizes multiple test classes or tests so they can be run together.
Question 18 of 60 · Example JUnit Test · Easy
Which assertion checks that two values are equal in JUnit?
Not quite. Try another option.
Answer: assertEquals
assertEquals compares an expected value with an actual value and reports a failure when they differ.
Question 19 of 60 · JUnit Code Constructs · Easy
Which JUnit construct is used to check an expected result?
Not quite. Try another option.
Answer: Assertion
Assertions compare actual results with expected results and determine whether a test passes.
Question 20 of 60 · Eclipse Support for JUnit · Easy
Which Eclipse feature can run a JUnit test class?
Not quite. Try another option.
Answer: Run As JUnit Test
Eclipse provides a Run As JUnit Test option for executing JUnit tests and viewing their results.
Question 21 of 60 · Testing Tools Selection Criteria · Medium
A development team needs a Java testing tool that supports parameterized tests, parallel execution, and flexible grouping of tests. Which tool best satisfies these requirements?
Not quite. Try another option.
Answer: TestNG
TestNG provides built-in support for parameterization, parallel execution, dependencies, and test groups.
Question 22 of 60 · Testing Tools Selection Criteria · Medium
A team is selecting an automated testing tool for a long-term project. Which factor is most important for reducing integration effort?
Not quite. Try another option.
Answer: Compatibility with the existing technology stack
A tool compatible with the project's languages, build system, CI platform, and environment requires less custom integration work.
Question 23 of 60 · Fundamentals of Jenkins · Medium
A Jenkins pipeline must compile a Maven project and then execute its unit tests. Which sequence of stages is most appropriate?
Not quite. Try another option.
Answer: Checkout followed by build and test
Jenkins must first obtain the source code, after which Maven can compile the project and execute its tests.
Question 24 of 60 · Fundamentals of Jenkins · Medium
A Jenkins job should run automatically whenever code is pushed to a Git repository. Which mechanism is most suitable?
Not quite. Try another option.
Answer: A repository webhook
A webhook notifies Jenkins immediately after a repository event, allowing the configured job or pipeline to start automatically.
Question 25 of 60 · TestNG · Medium
A TestNG test method should run with three different username and password combinations. Which TestNG feature should be used?
Not quite. Try another option.
Answer: @DataProvider
@DataProvider supplies multiple sets of arguments to a TestNG test method, causing it to run once for each data set.
Question 26 of 60 · TestNG · Medium
In TestNG, generateReport() must run only after executeTests() completes successfully. Which configuration expresses this requirement?
Not quite. Try another option.
Answer: dependsOnMethods = "executeTests"
dependsOnMethods defines a dependency between TestNG methods and skips the dependent test when its required method fails.
Question 27 of 60 · Maven · Medium
A Maven project stores its JUnit tests under src/test/java. Which command compiles the project and runs those tests without packaging the application?
Not quite. Try another option.
Answer: mvn test
mvn test executes the Maven lifecycle through the test phase, including compilation of source and test classes.
Question 28 of 60 · Maven · Medium
JUnit should be available when compiling and running tests but should not be included as a runtime dependency of the application. Which Maven dependency scope is appropriate?
Not quite. Try another option.
Answer: test
The test scope makes JUnit available during test compilation and execution without adding it to the application's runtime classpath.
Question 29 of 60 · JUnit 5 · Medium
A JUnit 5 test must execute the same method for the values 2, 4, and 6. Which annotation combination is appropriate?
Not quite. Try another option.
Answer: @ParameterizedTest with @ValueSource
@ParameterizedTest defines a parameterized test, while @ValueSource supplies the individual argument values.
Question 30 of 60 · JUnit 5 · Medium
A JUnit 5 test should verify that calling withdraw(200) on an account with insufficient funds throws InsufficientFundsException. Which assertion should be used?
assertThrows executes the supplied code and succeeds only when an exception of the expected type is thrown.
Question 31 of 60 · Gherkin · Medium
Which Gherkin scenario correctly describes a successful login using behavior-focused steps?
Not quite. Try another option.
Answer: Given the login page is open, When valid credentials are submitted, Then the dashboard is displayed
Good Gherkin describes an initial context, a user action, and an observable outcome without exposing low-level implementation details.
Question 32 of 60 · Gherkin · Medium
Several Gherkin scenarios require the user to be authenticated before their individual steps begin. Where should the shared authentication step be placed?
Not quite. Try another option.
Answer: In a Background section
A Background contains common Given steps that run before each scenario in the feature.
Question 33 of 60 · Introduction to JUnit Framework · Medium
A developer changes the implementation of a calculator while keeping its public behavior unchanged. How does a JUnit regression suite help?
Not quite. Try another option.
Answer: It verifies that existing tested behavior still passes
Re-running JUnit tests after a code change helps detect regressions in behavior that was previously working.
Question 34 of 60 · Define a Test in JUnit · Medium
Which JUnit 5 method is correctly defined as a test?
A descriptive test name identifies the behavior under test, the relevant condition, and the expected outcome.
Question 36 of 60 · JUnit Test Suites · Medium
A JUnit 5 suite should include every test class in the package com.example.payment. Which suite configuration is appropriate?
Not quite. Try another option.
Answer: @Suite with @SelectPackages("com.example.payment")
@Suite declares a JUnit Platform suite, and @SelectPackages selects tests from the specified package.
Question 37 of 60 · Example JUnit Test · Medium
A method isEven(8) returns true. Which JUnit assertion most directly verifies this behavior?
Not quite. Try another option.
Answer: assertTrue(isEven(8))
assertTrue directly verifies that a boolean expression evaluates to true.
Question 38 of 60 · JUnit Code Constructs · Medium
A fresh DatabaseConnection must be created before every JUnit 5 test to prevent tests from sharing state. Which annotation should be applied to the setup method?
Not quite. Try another option.
Answer: @BeforeEach
A method annotated with @BeforeEach runs before every test method, making it suitable for creating isolated test fixtures.
Question 39 of 60 · Eclipse Support for JUnit · Medium
A JUnit test run in Eclipse displays a red progress bar, although most tests passed. What does the red bar indicate?
Not quite. Try another option.
Answer: At least one test failed or produced an error
In Eclipse's JUnit view, a red result bar means the test run contains at least one failure or error.
Question 40 of 60 · Installation of JUnit · Medium
A Maven-based Java project needs JUnit 5 tests to run during mvn test. Which setup is required?
Not quite. Try another option.
Answer: Add a JUnit Jupiter dependency with test scope
Declaring JUnit Jupiter as a Maven test dependency places the required JUnit 5 APIs and engine on the test classpath.
Question 41 of 60 · Testing Tools Selection Criteria · Hard
A Java team must select a testing tool for a modular application. The build runs offline in a restricted network, tests require parallel execution, and reports must integrate with an existing CI server. Which evaluation approach best reduces adoption risk?
Not quite. Try another option.
Answer: Run a proof of concept against weighted mandatory criteria
A proof of concept validates critical constraints such as offline dependency resolution, parallelism, modular Java support, and CI reporting. Weighted mandatory criteria prevent popularity or familiarity from overriding essential requirements.
Question 42 of 60 · Testing Tools Selection Criteria · Hard
Two candidate tools satisfy all functional requirements. Tool X has lower license cost but requires proprietary test scripts, while Tool Y uses standard Java APIs and integrates with the current Maven lifecycle. Which factor most strongly favors Tool Y over the application's expected ten-year lifetime?
Not quite. Try another option.
Answer: Its tests are more portable and have lower migration risk
Standard APIs and native build integration reduce vendor lock-in, maintenance cost, and future migration risk. Total cost of ownership is often more significant than the initial license price.
Question 43 of 60 · Fundamentals of Jenkins · Hard
A Jenkins Pipeline uses the following stage:
stage('Test') { steps { sh 'mvn test' } post { always { junit 'target/surefire-reports/*.xml' } } }
Several tests fail. Assuming Maven Surefire returns a nonzero exit code, what is the most likely behavior?
Not quite. Try another option.
Answer: The stage fails, but Jenkins still attempts to publish the XML reports
A failing sh step marks the stage unsuccessful, but a stage-level post { always { ... } } block still executes. This allows Jenkins to publish test reports even after test failures.
Question 44 of 60 · Fundamentals of Jenkins · Hard
A Jenkins controller has Linux and Windows agents. UI tests require Chrome installed only on agents labeled ui-linux, while compilation may run anywhere. Which Declarative Pipeline design most accurately enforces this constraint?
Not quite. Try another option.
Answer: Use agent none globally and assign agents to individual stages
With agent none, each stage can request an appropriate agent. The compilation stage can use any suitable node, while the UI stage can explicitly require the ui-linux label.
Question 45 of 60 · TestNG · Hard
A TestNG data provider is declared as @DataProvider(name = "users", parallel = true). Multiple invocations update the same mutable instance field in the test class. Which change most directly makes the tests reliable under parallel execution?
Not quite. Try another option.
Answer: Move invocation-specific state into local variables or parameters
Parallel data-provider invocations may access the same test instance concurrently. Keeping invocation state local or passing it as parameters avoids races caused by shared mutable fields.
Question 46 of 60 · TestNG · Hard
In TestNG, createAccount() is annotated with @Test, and deleteAccount() is annotated with @Test(dependsOnMethods = "createAccount"). If createAccount() fails, what is the default outcome for deleteAccount()?
Not quite. Try another option.
Answer: It is skipped because a required dependency failed
TestNG skips a dependent test when its required method fails. Setting alwaysRun = true can change this behavior for cases such as cleanup that must execute despite dependency failure.
Question 47 of 60 · Maven · Hard
A Maven project has unit tests named PriceTest and integration tests named PaymentIT. The build must run unit tests during test and integration tests during integration-test, with integration-test failures checked during verify. Which plugin allocation is conventional?
Not quite. Try another option.
Answer: Surefire for PriceTest and Failsafe for PaymentIT
Surefire normally runs unit tests in the test phase. Failsafe is designed for integration tests and separates execution from result verification so cleanup phases can still run.
Question 48 of 60 · Maven · Hard
A multi-module Maven build contains modules domain, service, and web, where web depends on service, and service depends on domain. From the reactor root, what does mvn -pl service -am test request?
Not quite. Try another option.
Answer: Test service and also build its required reactor dependencies
-pl service selects the service project, while -am means "also make" its required reactor dependencies. Therefore, Maven includes domain, but not the downstream web module.
Question 49 of 60 · JUnit 5 · Hard
A JUnit Jupiter parameterized test receives strings through @ValueSource(strings = {"42", "-1"}), but the method parameter type is int. Why can this test execute without a custom converter?
Not quite. Try another option.
Answer: Jupiter performs a supported implicit string-to-integer conversion
JUnit Jupiter supports implicit conversion from String values to several common target types, including primitive numeric types and their wrappers. Java autoboxing alone cannot convert a String to an int.
Question 50 of 60 · JUnit 5 · Hard
A JUnit Jupiter test class uses the default per-method lifecycle. Its non-static @BeforeAll method fails discovery with a validation error. Which change permits the method to remain non-static?
Not quite. Try another option.
Answer: Annotate the class with @TestInstance(PER_CLASS)
Under PER_CLASS, Jupiter creates one test instance for the class, allowing @BeforeAll and @AfterAll methods to be non-static. The default PER_METHOD lifecycle generally requires them to be static.
Question 51 of 60 · Gherkin · Hard
A Gherkin scenario outline contains placeholders <role> and <status>, with three rows in its Examples table. How should a runner normally interpret the outline?
Not quite. Try another option.
Answer: As three scenario instances with row-specific substitutions
Each Examples row creates one scenario instance. Values from the same row replace the corresponding placeholders; columns are not independently combined into a Cartesian product.
Question 52 of 60 · Gherkin · Hard
Which Gherkin design best preserves business readability while avoiding unnecessary coupling to a web interface?
Not quite. Try another option.
Answer: When the customer submits a valid refund request
Gherkin should describe observable business behavior rather than implementation mechanics. UI selectors, protocol calls, and timing details belong in step definitions or supporting automation code.
Question 53 of 60 · Introduction to JUnit Framework · Hard
A project contains JUnit 4 tests and newly written JUnit Jupiter tests. Maven discovers the Jupiter tests but ignores the JUnit 4 tests. Which additional JUnit Platform component is specifically intended to execute the older tests?
Not quite. Try another option.
Answer: The JUnit Vintage test engine
The Vintage engine runs JUnit 3 and JUnit 4 tests on the JUnit Platform. The Jupiter engine handles tests written with the JUnit Jupiter programming model.
The transfer throws a subclass of InsufficientFundsException. What is the result?
Not quite. Try another option.
Answer: The assertion passes because assertThrows accepts subclasses
assertThrows succeeds when the executable throws the expected type or any subtype. JUnit Jupiter provides assertThrowsExactly when an exact exception class is required.
Question 55 of 60 · JUnit Naming Conventions · Hard
A Maven project uses the default Surefire test-name patterns. Which JUnit test class is least likely to be discovered solely because of its filename?
Not quite. Try another option.
Answer: PaymentSpecification.java
Default Surefire patterns commonly include names such as Test*, *Test, *Tests, and *TestCase. PaymentSpecification does not normally match those conventions unless plugin includes are customized.
Question 56 of 60 · JUnit Test Suites · Hard
A JUnit Platform suite is annotated with @Suite, @SelectPackages("com.example"), and @IncludeTags("fast"). What is the intended selection behavior?
Not quite. Try another option.
Answer: Discover tests in com.example and retain those tagged fast
Package selectors define the discovery scope, while tag filters narrow the discovered tests. The annotations do not assign tags or establish execution order.
Question 57 of 60 · Example JUnit Test · Hard
A JUnit Jupiter test uses assertAll("account", () -> assertEquals(10, account.balance()), () -> assertFalse(account.isLocked())). Both assertions fail. What behavior should be expected?
Not quite. Try another option.
Answer: Both assertions execute and their failures are reported together
assertAll groups assertions and evaluates each executable, reporting multiple failures together. This is useful when several related properties should be checked in one test.
Question 58 of 60 · JUnit Code Constructs · Hard
A JUnit Jupiter test calls assertTimeout(Duration.ofMillis(100), () -> service.compute()), and compute() takes 150 ms before returning normally. Which statement is correct?
Not quite. Try another option.
Answer: The executable completes on the calling thread, then the assertion fails
assertTimeout measures execution but does not preempt it; the code completes before the timeout failure is reported. assertTimeoutPreemptively uses preemptive execution and has different thread-related implications.
Question 59 of 60 · Eclipse Support for JUnit · Hard
A JUnit Jupiter test runs from Maven, but Eclipse reports that no tests were found when using an outdated Eclipse installation. The project classpath is otherwise correct. What is the most appropriate diagnosis?
Not quite. Try another option.
Answer: The Eclipse JUnit launcher lacks compatible JUnit 5 support
Older Eclipse releases may not include a launcher compatible with JUnit 5. Updating Eclipse or installing appropriate JUnit tooling resolves IDE discovery while Maven can continue using its own provider.
Question 60 of 60 · Installation of JUnit · Hard
A Maven project should compile and run JUnit Jupiter tests without packaging JUnit APIs into the production artifact. Which dependency setup is most appropriate when dependency versions are managed separately?
Not quite. Try another option.
Answer: org.junit.jupiter:junit-jupiter with scope test
The junit-jupiter aggregate dependency supplies the Jupiter API, parameters support, and engine for typical test execution. Maven's test scope keeps these dependencies off the production runtime classpath and artifact.
That's unit 4
Answer a few questions and your score shows up here.
Nearly through. Did unit 4 of CSE376 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 4 of CSE376 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.