Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to mark the test method as dependent on another test.
Selenium Java
@Test(dependsOnMethods = [1])
public void testLogin() {
// test code here
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the method name in quotes.
Using the wrong method name.
✗ Incorrect
The dependsOnMethods attribute requires the name of the method as a string in quotes inside an array {}.
2fill in blank
mediumComplete the code to skip the test if the dependent test fails.
Selenium Java
@Test(dependsOnMethods = {"testSetup"}, [1] = false)
public void testFeature() {
// test code here
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using skipFailedDependencies (invalid attribute).
Using enabled which controls if the test runs at all.
✗ Incorrect
alwaysRun = false makes the test skip if the dependent test fails.
3fill in blank
hardFix the error in the test dependency annotation to correctly depend on testInit.
Selenium Java
@Test(dependsOnMethods = [1])
public void testProcess() {
// test code
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the method name.
Using a wrong method name.
✗ Incorrect
The method name must be a string in quotes inside the dependsOnMethods array {}.
4fill in blank
hardFill both blanks to create a test that depends on testLogin and skips if it fails.
Selenium Java
@Test(dependsOnMethods = [1], [2] = false) public void testDashboard() { // test code }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using braces for dependsOnMethods array.
Using skipFailedDependencies instead of alwaysRun.
✗ Incorrect
dependsOnMethods needs an array of method names in braces and alwaysRun=false skips if dependency fails.
5fill in blank
hardFill both blanks to create a test depending on testSetup and testLogin, skipping if either fails.
Selenium Java
@Test(dependsOnMethods = [1], [2] = false) public void testFinal() { // test code }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using an array for multiple dependencies.
Using skipFailedDependencies instead of alwaysRun.
Setting alwaysRun to true instead of false.
✗ Incorrect
dependsOnMethods takes an array of method names, alwaysRun=false skips on failure.