0
0
Selenium Javatesting~20 mins

Running tests via Maven in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Maven Test Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output when running Maven test with this POM snippet?

Given this Maven pom.xml snippet configuring the Surefire plugin to run tests, what will be the output when you run mvn test?

Selenium Java
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.0.0-M7</version>
  <configuration>
    <includes>
      <include>**/*Test.java</include>
    </includes>
  </configuration>
</plugin>
AMaven skips tests because no test classes are specified in the configuration.
BMaven runs all Java files ending with 'Tests.java' as test classes and reports test results.
CMaven runs all Java files in the src/main/java folder as tests and reports results.
DMaven runs all Java files ending with 'Test.java' as test classes and reports test results.
Attempts:
2 left
💡 Hint

Look carefully at the <include> pattern used in the Surefire plugin configuration.

assertion
intermediate
2:00remaining
Which Maven command runs tests and skips compiling the main code?

You want to run tests using Maven but skip compiling the main source code to save time. Which command achieves this?

Amvn test -Dmaven.main.skip=true
Bmvn test -DskipCompile=true
Cmvn test -Dmaven.compiler.skipMain=true
Dmvn test -DskipTests=false
Attempts:
2 left
💡 Hint

Check the correct Maven property to skip compiling main code.

🔧 Debug
advanced
3:00remaining
Why does Maven fail to find tests when running mvn test?

Given this project structure and pom.xml configuration, Maven fails to find any tests when running mvn test. What is the most likely cause?

Project structure:
src/
  main/
    java/
  test/
    java/
      com/example/tests/MyTest.java

pom.xml snippet:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>

AThe Surefire plugin version 3.0.0-M7 does not support Java test execution.
BThe include pattern '**/*Tests.java' does not match 'MyTest.java', so no tests are found.
CThe test source folder is incorrectly named 'test' instead of 'tests'.
DThe test class 'MyTest.java' is missing the @Test annotation.
Attempts:
2 left
💡 Hint

Check the file name and the include pattern carefully.

framework
advanced
3:00remaining
How to configure Maven to run only tests tagged with @Category(SmokeTests.class)?

You want Maven to run only tests marked with the JUnit 4 category @Category(SmokeTests.class). Which Surefire plugin configuration snippet achieves this?

A
&lt;configuration&gt;
  &lt;includedGroups&gt;com.example.categories.SmokeTests&lt;/includedGroups&gt;
&lt;/configuration&gt;
B
&lt;configuration&gt;
  &lt;groups&gt;com.example.categories.SmokeTests&lt;/groups&gt;
&lt;/configuration&gt;
C
&lt;configuration&gt;
  &lt;tags&gt;SmokeTests&lt;/tags&gt;
&lt;/configuration&gt;
D
&lt;configuration&gt;
  &lt;excludedGroups&gt;com.example.categories.SmokeTests&lt;/excludedGroups&gt;
&lt;/configuration&gt;
Attempts:
2 left
💡 Hint

Look for the correct Surefire configuration element to include test groups.

🧠 Conceptual
expert
3:00remaining
What is the effect of running mvn clean test -Dtest=MyTest#testMethod?

Explain what happens when you run the following Maven command:

mvn clean test -Dtest=MyTest#testMethod
AMaven cleans the project, then runs only the single test method 'testMethod' in the 'MyTest' class.
BMaven cleans the project, then runs all tests in the 'MyTest' class except 'testMethod'.
CMaven cleans the project, then runs all tests in all classes matching 'MyTest*'.
DMaven cleans the project, then runs all tests in the project ignoring the -Dtest parameter.
Attempts:
2 left
💡 Hint

Check how the -Dtest parameter with method name works.