0

I have written a piece of java code in Eclipse IDE.My code is under src/test/java directory and there is a dummy class at src/main/java and am able to run my code by using testng in eclipse.

code at src/main/java:

package Maven.Maven1;

public class MainJavaProgram {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.out.println("Java program uder src-main-java is running");
    }

}

Code at src/test/java (which am expecting to be executed):

package com.TestClass;


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;


public class MyFirstProgram {

    @Test
    public void TestMethod() {
    //public static void main(String arg[]) {   
        System.out.println("Welcome to DevOps");

        System.setProperty("webdriver.chrome.driver", "C:\\WebDrivers\\chromedriver_win32\\chromedriver.exe");

        WebDriver driver= new ChromeDriver();
        driver.manage().deleteAllCookies();
        driver.manage().window().maximize();
        System.out.println("ChromeDriver is successfully launched");
        driver.get("https://www.google.com/");
        System.out.println("You are in Given webPage");

        String title=driver.getTitle();
        System.out.println("Title is " +title);
        driver.quit();
    }


}

When i try to do the same in command prompt using maven, my build has been succeeded but the code is not executing.

maven command used: mvn clean install Result:

C:\EclipseCode\Maven1>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< Maven:Maven1 >----------------------------
[INFO] Building Maven1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Maven1 ---
[INFO] Deleting C:\EclipseCode\Maven1\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Maven1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\EclipseCode\Maven1\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Maven1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\EclipseCode\Maven1\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Maven1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\EclipseCode\Maven1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Maven1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\EclipseCode\Maven1\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Maven1 ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ Maven1 ---
[INFO] Building jar: C:\EclipseCode\Maven1\target\Maven1-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Maven1 ---
[INFO] Installing C:\EclipseCode\Maven1\target\Maven1-0.0.1-SNAPSHOT.jar to C:\Users\ELCOT\.m2\repository\Maven\Maven1\0.0.1-SNAPSHOT\Maven1-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\EclipseCode\Maven1\pom.xml to C:\Users\ELCOT\.m2\repository\Maven\Maven1\0.0.1-SNAPSHOT\Maven1-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.106 s
[INFO] Finished at: 2019-03-22T21:39:44+05:30
[INFO] ------------------------------------------------------------------------

i have tried all the blogs to solve this issue but no luck.

it would be really helpful, could someone help me to solve this issue.

  • @azurefrog i have updated it – user10763044 Mar 22 '19 at 16:46
  • 2
    Possible duplicate of [Maven does not find JUnit tests to run](https://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run) – azurefrog Mar 22 '19 at 16:46
  • 1
    Thanks a lot @azurefrog, it was a miss in naming convention, i have changed the class name from MyFirstProgram to MyFirstProgramTest. Now My code is getting executed. – user10763044 Mar 22 '19 at 17:04
  • Also am trying to run my code from Jenkins but getting this warning and there is no testng report has generated - **[JENKINS] Recording test results [WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.SurefireArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/ [WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.BuildInfoRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/ ** And there is no testNG report has generated, it says "Did not find any matching files." – user10763044 Mar 22 '19 at 17:32
  • Could someone please help me on above ask – user10763044 Mar 22 '19 at 18:56
  • 1
    Instead of asking a follow-up question as a comment on the original, you should post a new question and include a link back to this one for context. – azurefrog Mar 22 '19 at 19:07

0 Answers0