Cucumber runner file is not running any Tests - selenium

I have checked the related questions, but couldn't find any answer for my problem.
I am trying to set up cucumber framework from scratch.
I set up the POM, test runner, a feature file and related step definitions.
But when I run the test, there is no error but none of the test runs. I tried giving glue also in my runner file. Its not running from intellij as well as from command line.
Giving all the files for reference. Please see if anybody is able to point the error I am making?
POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.demo</groupId>
<artifactId>TestCucumber</artifactId>
<version>1.0-SNAPSHOT</version>
<name>TestCucumber</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<cucumber.version>7.2.3</cucumber.version>
<maven-cucumber-reporting.version>5.6.1</maven-cucumber-reporting.version>
<project.name>TestCucumber</project.name>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>${maven-cucumber-reporting.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>${maven-cucumber-reporting.version}</version>
<executions>
<execution>
<id>execution-dwp-employment-income-api</id>
<goals>
<goal>generate</goal>
</goals>
<!-- report generation is happening at this phase, so please dont change-->
<phase>integration-test</phase>
<configuration>
<projectName>${project.name}</projectName>
<skip>false</skip>
<!-- output directory for the generated report -->
<outputDirectory>${project.build.directory}/jsonReports/reports</outputDirectory>
<!-- optional, defaults to outputDirectory if not specified -->
<inputDirectory>${project.build.directory}/jsonReports</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>**/*.json</param>
</jsonFiles>
<mergeFeaturesById>false</mergeFeaturesById>
<!-- optional, set true to get a final report with latest results of the same test from different test runs -->
<mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
<!-- optional, set true to fail build on test failures -->
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Runner File
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
features = "src/test/resources/features",
tags = "#Test",
monochrome = true,
plugin = {"json:target/cucumber.json"}
)
public class CucumberTestDebugger {
}
Feature file
#Test
Feature: As user I want to Validate the feature
Scenario : Scenario 1 for the Feature
Given A sample record is present
Step definition
import io.cucumber.java.en.Given;
public class Feature1Step {
#Given("A sample record is present")
public void aSampleScenario() {
System.out.println("RECORD IS PRESENT");
}
}
Even if I just run the feature file for which step definition is not defined, that scenario also doesn't run. Usually it should give error for undefined steps in feature. It just shows -
C:\Users\myname\Java\jdk8\bin\java.exe -C:/Users/myname/IdeaProjects/TestCucumber/src/test/resources/features/Validate.feature
Testing started at 16:34 ...
0 Scenarios
0 Steps
0m0.324s
Thanks in advance!!!

Aggghhhhh..... I had an extra space after Scenario.
Silly mistake !!! Took hours
**Before**
Scenario : Scenario 1 for the Feature
**After**
Scenario: Scenario 1 for the Feature

Related

Selenium (Eclipse) - feature file - step is not highlighted if step definition is undefined

I am very new to Selenium and Cucumber.
I am asking for your kind advice.
My problem is: Feature file - step is not highlighted, not showing warning messages if step definition is undefined.
My Feature file:
[![enter image description here][1]][1]
My runner:
[![enter image description here][2]][2]
Maven dependencies:
[![enter image description here][3]][3]
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>linkedlearning</groupId>
<artifactId>Mycucumbercourse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Mycucumbercourse</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.version>4.11</junit.version>
<cucumber.version>4.2.5</cucumber.version>
<maven.compiler.version>3.3</maven.compiler.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<!-- hamcrest dependency required in order to be able to run test using maven (command: mvn test) -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I tried to investigate myself and find that import io.cucumber.junit.CucumberOptions; in combination with stepNotifications = true may help. However when I try to add it I am getting: "The import io.cucumber.junit cannot be resolved". Looking forward for your kind advice.
[1]: https://i.stack.imgur.com/KcrQN.png
[2]: https://i.stack.imgur.com/t2h9a.png
[3]: https://i.stack.imgur.com/n2gFr.png
I found an answer here:
Step Definition detection only works when project is configured as cucumber project.- Virtual Machine
Generally speaking:
If the step definition is not happened and the feature file does not highlight undefined steps with amber color that means that the project is not converted as a cucumber project.
Do the following:
In order to convert the project as a cucumber project do the following: Right-click on your project from the Project Explorer > Configure > Convert as Cucumber Project.
Ensure option Enable Step Definitions Glue Detection is checked in Window > Preferences > Cucumber

Groovy script is not executing in the Camel (Project)

Scenario: Just wanted to transfer the files from one location to another
location using camel and groovy script
Problem: I am not seeing any errors in the console, but how can we make
sure script is executing.
Sample MainApp Program :
class MainApp {
static void main(String... args) {
def camelContext = new DefaultCamelContext()
println("printing something in the console MainApp")
camelContext.addRoutes( new RouteBuilder() {
#Override
void configure() {
println("Printing some thing before queue")
from("Test").to("Test")
println("printing something after queue")
}
})
//camelContext.start()
// Thread.sleep(10000)
// camelContext.stop()
}
}
Output :
sampling ...
include patterns:
org\.apache\.camel\..*
exclude patterns:
printing something in the console MainApp
Printing some thing before queue
printing something after queue
Process finished with exit code 0
Pom.xml file: If you could observe, below file contains all the jar files which are related to groovy and camel.. (I am thinking there are problems with pom file.. please let me know if you are finding out the same)
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SampleCamelProject</groupId>
<artifactId>camel-example-groovy</artifactId>
<packaging>jar</packaging>
<version>0.0.0</version>
<name>SampleCamelProject</name>
<properties>
<maven-compiler-plugin-version>3.8.0</maven-compiler-plugin-version>
<maven-resources-plugin-version>3.1.0</maven-resources-plugin-version>
<maven-eclipse-plugin-version>2.10</maven-eclipse-plugin-version>
<exec-maven-plugin-version>1.6.0</exec-maven-plugin-version>
<camel-core-version>2.13.3</camel-core-version>
<camel-groovy-dsl-version>2.19.5</camel-groovy-dsl-version>
<camel-jetty-version>1.6.0</camel-jetty-version>
<log4j-api-version>2.11.1</log4j-api-version>
<log4j-core-version>2.11.1</log4j-core-version>
<log4j-slf4j-version>2.11.1</log4j-slf4j-version>
</properties>
<description>A Camel route using Groovy DSL</description>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-core-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy-dsl</artifactId>
<version>${camel-groovy-dsl-version}</version>
</dependency>
<!-- used for jetty -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
<version>${camel-jetty-version}</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j-api-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j-core-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j-slf4j-version}</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin-version}</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin-version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerId>groovy-eclipse-compiler</compilerId>
<!-- set verbose to be true if you want lots of uninteresting messages -->
<!-- <verbose>true</verbose> -->
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.2-01</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.4.3-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${maven-eclipse-plugin-version}</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin-version}</version>
<configuration>
<mainClass>org.apache.camel.MainAppTest</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>jdk9-build</id>
<activation>
<jdk>9</jdk>
</activation>
<build>
<plugins>
<plugin>
<!--Skip compile on Java 9 https://issues.apache.org/jira/browse/CAMEL-10905 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Above same app I executed in java: I am getting an error(As expected)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to
create route route1: Route(route1)[[From[Test]] -> [To[Test]]] because
of No endpoint could be found for: Test, please check your classpath
contains the needed Camel component jar.
The same thing I am expecting from groovy script .. please suggest me if
I am missing anything.
I am giving myself an answer to the above question. I haven't thought of executing a simple way of writing Groovy script. I have tried below code and it is working.
package org.apache.camel
import org.apache.camel.impl.*
import org.apache.camel.builder.*
def camelContext = new DefaultCamelContext()
camelContext.addRoutes(new RouteBuilder() {
def void configure() {
from("Test")
.to("Test")
}
})
camelContext.start()
addShutdownHook{ camelContext.stop() }
synchronized(this){ this.wait() }
Maybe we can make execute above-posted question with the groovy script .. but I am not seeing any console logs when an error occurs. Please suggest me on this .. I really would like to know how the process executes .. thanks a lot advance.

running test suite is not working in junit5 through maven

#SelectPackages and #SelectClasses tags are not getting parsed with maven test command.Though it is working fine in IDE. Even I tried with tag inside pom.xml.
Here is the code snippet :
PaymentServiceTest.java
package xyz.howtoprogram.junit5.payment;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
#RunWith(JUnitPlatform.class)
public class PaymentServiceTest {
#Test
public void doPaymentZeroAmount() {
assertEquals(1, 1);
}
}
UserFeatureSuiteTest.java
#RunWith(JUnitPlatform.class)
#SelectPackages("xyz.howtoprogram.junit5.payment")
public class UserFeatureSuiteTest {
}
It is not running any of the test cases under the package. Though there is one test case underneath it.
xyz.howtoprogram.junit5.payment
-> PaymentServiceTest.java
Running xyz.howtoprogram.junit5.suite.UserFeatureSuiteTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec - in xyz.howtoprogram.junit5.suite.UserFeatureSuiteTest.
Even I tried with changing the pom.xml like adding the 'include' tag.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
<junit.vintage.version>4.12.0-M2</junit.vintage.version>
<junit.platform.version>1.0.0-M2</junit.platform.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/UserFeatureSuiteTest.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
</dependencies>
Sorry for the confusion ... I just took a closer look at your code and realized you're trying to mix two concepts.
Your test code is annotated with the JUnit 5 #Test. Therefore this code must be run with the junit-jupiter-engine. That engine does NOT support declarative suites but does read in the configuration from the maven-surefire-plugin.
#RunWith is a JUnit4 annotation and is completely ignored within the junit-jupiter-engine. I don't think it will cause the test to fail but it also will not enable any JUnit 5 tests. The #SelectPackages annotation you've placed on your suite's class will, in this context, only help decide which JUnit 4 tests are run - but you don't have any.
Below is the final POM,it is working now.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.howtoprogram</groupId>
<artifactId>junit5-test-suite-example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
<junit.vintage.version>4.12.0-M2</junit.vintage.version>
<junit.platform.version>1.0.0-M2</junit.platform.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<includes>
<include>**/*SuiteTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
so the output is :
T E S T S
-------------------------------------------------------
Feb 23, 2017 10:21:06 PM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
INFO: Discovered TestEngines with IDs: [junit-jupiter]
Running xyz.howtoprogram.junit5.suite.UserFeatureSuiteTest
Feb 23, 2017 10:21:06 PM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
INFO: Discovered TestEngines with IDs: [junit-jupiter]
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec - in xyz.howtoprogram.junit5.suite.UserFeatureSuiteTest
#RunWith(JUnitPlatform.class) is not supported when running tests via the JUnit Platform. If the new provider would pickup both UserFeatureSuiteTest and PaymentServiceTest your tests would be executed twice.
From the User Guide:
Annotating a class with #RunWith(JUnitPlatform.class) allows it to be run with IDEs and build systems that support JUnit 4 but do not yet support the JUnit Platform directly.
Thus, if you want UserFeatureSuiteTest to be run by Maven Surefire, you can use the "old" JUnit 4 support that is detected by default, i.e. just remove junit-platform-surefire-provider from the plug-in's dependencies.
Alternatively, you can directly execute your tests, e.g. PaymentServiceTest, through the JUnit Platform with your existing configuration.
By default Maven uses the following naming conventions when looking for tests to run:
Test*
*Test
*TestCase
Your test class doesn't follow these conventions. You should rename it or configure Maven Surefire Plugin to use another pattern for test classes.
Another thing that could lead to your Maven to not work is that all the tests are supposed to be in the following folder:
/my_application/src/test/java/MyFirstExampleTest.java
Here you can see a quite good question for a generalization of your problem, from where I took some parts of my answer. You should take a look at it.
EDIT
Here you can see an example that explain how your pom.xml should be:
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codefx.demo</groupId>
<artifactId>junit-5</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M3</version>
</dependency>
<dependency>
<!-- contains the engine that actually runs the Jupiter-tests -->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
As you can see in this configuration file you specify:
Dependency: you need a test scoped dependency of JUnit in order to run tests
In the build section you will add the surefire plugin that will run your tests along with its dependencies

Robot Framework: Getting build error for missing Jar

I have started learning Robot Framework (with Java & selenium lib) and was trying to write a simple test case in it. Could you please help me with it.
I have copied tools jar in the mentioned lib and also in the dependancy
But still did not work
Following is the error
Failed to execute goal org.robotframework:robotframework-maven-plugin:1.4.6:run (default-cli) on project JavaRobot: Execution default-cli of goal org.robotframework:robotframework-maven-plugin:1.4.6:run failed: Plugin org.robotframework:robotframework-maven-plugin:1.4.6 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:6 at specified path C:\Program Files\Java\jre1.8.0_101/../lib/tools.jar -> [Help 1]
Here is my POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.Robot</groupId>
<artifactId>JavaRobot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JavaRobot</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.robotframework</groupId>
<artifactId>robotframework</artifactId>
<version>2.8.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>C:\Program Files\Java\jdk1.8.0_101\lib\tools.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.markusbernhardt</groupId>
<artifactId>robotframework-selenium2library-java</artifactId>
<version>1.4.0.8</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.4.6</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Try to add the exclusion , I think it will fix your problem.
Example:
<dependency>
<groupId>com.github.markusbernhardt</groupId>
<artifactId>robotframework-selenium2library-java</artifactId>
<version>1.4.0.7</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>tools</artifactId>
<groupId>com.sun</groupId>
</exclusion>
</exclusions>

Unable to Deploy war using maven 3.x

I am trying to deploy my web-application to tomcat using maven 3.x here is the snap shot of the pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>demoapp</artifactId>
<version>2.2.3</version>
<packaging>war</packaging>
<name>Blank Webapp</name>
<properties>
<struts2.version>2.2.3</struts2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>${struts2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
<url>http://localhost:8080/manager/html</url>
<server>localhost</server>
<path>/WebApp</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
i tried the following goal in maven mvn deploy but i got the following build fail with following error
Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
after doing some googling i added the following entry to my pom.xml
<distributionManagement>
<repository>
<id>myRepoId</id>
<name>myCompanyReporsitory</name>
<!-- <url>scp://nothing/</url>
<url>${user.home}/m2/repository</url> -->
</repository>
</distributionManagement>
but i am not sure what should be the URL since using ${user.home}/m2/repository gave another error with build failure
Failed to deploy artifacts/metadata: No connector available to access repository myRepoId (C:\Users\admin/m2/repository) of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1]
How to solve the problem?
The mvn deploy tries to send the result of the package goal to the url of repository described in your POM.
I aims not at deploying a Web application on its server but to share the library produced with other.
If what you need is to deploy you webapp, then the tomcat plugin is a solution.
BTW: The connector issue when trying to deploy is due to the fact that to enable SCP you need to add the wagon-scp connector.