TestNG error when executing script in eclipse ide - selenium

This is the error when I am trying to execute script in selenium ide using testNG
[RemoteTestNG] detected TestNG version 6.12.0
java.lang.NoSuchMethodError: org.testng.remote.support.RemoteTestNG6_12.initializeEverything()V
at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

it looks really weird that detected version 6.12 but running with the other version.
AFAIK, selenium has an embedded TestNG which definitely older than 6.12.
from the screenshot, could you adjust the library order, to move "TestNG" upper of "Referenced Libraries": right click on the project -> Build Path -> Configure Build Path... -> on tab "Order and Export", select "TestNG", then click the "Up" button to move it up.
also, could you share the sample project here: https://github.com/cbeust/testng-eclipse/issues/355, so that probably can conduct a right fix at TestNG Eclipse Plugin
Edit:
It's a classpath issue, you need to remove the redundant and old testng-6.0.jar
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="D:/Softwares/selenium-java-3.4.0/lib/cglib-nodep-3.2.4.jar"/>
...
<classpathentry kind="lib" path="D:/Softwares/selenium-java-3.4.0/client-combined-3.4.0-nodeps.jar"/>
<!-- Nick: you need to remove this entry: testng-6.0.jar, it's recommended to use TESTNG_CONTAINER -->
<classpathentry kind="lib" path="C:/Users/orange/Downloads/testng-6.0.jar"/>
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Related

Visibility of plain jar in tycho-surefire-plugin

The problem
I am faced with the following scenario:
The sources of an Eclipse test plugin (tycho packaging type eclipse-test-plugin) depend on a "plain" jar (read: non-OSGi jar). I managed to get the tests to compile and run in Eclipse, however when running Maven/Tycho from the command line, tycho-surefire-plugin fails to execute the tests because the jar is not visible at test time. This results in a java.lang.NoClassDefFoundError while attempting to load a class from the jar.
Looking at mvn -e -X output does not reveal anything significant.
My question is, how can I include the jar in the classpath of tycho-surefire-plugin when running Maven/Tycho from the command line?
Attempts
Here is everything I have tried so far:
Use <extraRequirements> as per the tycho-surefire-plugin documentation. This however fails because the jar's packaging type is jar, while <extraRequirements> expects one of the eclipse-xxx packaging types.
For a good measure I also tried
<configuration>
<dependencies>
<dependency>
<groupId>. . .</groupId>
<artifactId>. . .</artifactId>
<version>. . .</version>
<scope>system</scope>
<systemPath>path-to-the-jar</systemPath>
</dependency>
</dependencies>
</configuration>
but the packaging type is still considered to be jar.
Use <argLine> as per tycho-surefire-plugin documentation:
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<argLine>-cp path-to-the-jar</argLine>
</configuration>
however this appears to have no effect as the java.lang.NoClassDefFoundError persists.
Include the jar in the Eclipse test plugin. The jar is present in the MANIFEST.MF
Bundle-ClassPath: the.jar
in the build.properties
bin.includes = META-INF/,\
the.jar
and in the .classpath (although this doesn't matter for tycho-surefire-plugin).
<classpathentry exported="true" kind="lib" path="the.jar"/>
tycho-surefire-plugin once again reports java.lang.NoClassDefFoundError.
Create a dedicated Eclipse plugin to house the jar. This is for the most part equivalent to 3, where the Eclipse test plugin simply depends on this new dedicated Eclipse plugin. The java.lang.NoClassDefFoundError still rears its head.
Transition to Tycho 2.x.x since it supports the Directory location type. Unfortunately it is not possible to include the jar in the target definition because its packaging type is jar.

IntelliJ IDEA won't find log4j2.xml after maven build

I have a maven project with log4j2 (2.9.0) and a configuration file in /src/main/java/resources/log4j2.xml. As long as I stay in IntelliJ this works fine and it logs just like I configured it.
If I now make a mvn clean install in the terminal (Ubuntu 14) and then start the main method of my program in IntelliJ, I will get an error that it won't find the log4j2 configuration file:
ERROR StatusLogger No log4j2 configuration file found. Using default
configuration: logging only errors to the console. Set system property
'log4j2.debug' to show Log4j2 internal initialization logging.
As soon as I make Build -> Rebuild Project in IntelliJ IDEA it will work again.
I don't really understand how an external maven build could confuse IntelliJ IDEA to not take the .xml in the local source code.
Any idea?
I found the solution.
IntelliJ copies the resources per default to /target/classes and that's the place where IntelliJ actually takes the log4j2.xml from. My maven build didn't do that and IntelliJ didn't rebuild the project, so it couldn't find the log4j2.xml
My solution was to put the log4j2.xml in a resource section of the pom:
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>${project.build.directory}/classes</targetPath>
<includes>
<include>**/log4j2.xml</include>
</includes>
</resource>
</resources>

Problems running Java 8 TestNG inside IntelliJ

I am writing a Maven application using OpenJDK 1.8 and running tests using TestNG.
When I run Maven from the command line everything works fine, but when I try to run the test inside IntelliJ, then the make process is displaying the following error:
java: javacTask: source release 8 requires target release 1.8
I have the project settings pointing to the 1.8 JDK and Project Language Level 8.
Inside Maven I have the following block (which I am guessing is not getting called yet as it seems to be the make causing the problem)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
I have even configured the Maven Runner JRE to point to the 1.8 JDK.
I just don't seem to be able to get IntelliJ 12.0.4 to run the tests properly
Am I missing something?
After the hint from CrazyCoder it turns out that .idea/compiler.xml had the following section in it
<bytecodeTargetLevel>
<module name="game" target="1.7" />
</bytecodeTargetLevel>
I changed this to:
<bytecodeTargetLevel>
<module name="game" target="1.8" />
</bytecodeTargetLevel>
and it worked
There is another way to make it. Go to Files->Other Settings->Type "javac" in the search bar -> change the JDK default to "1.8" or any version you target.
Xetius' answer didn't work for me in IntelliJ 14.1.2
In the end I found the section in .idea/misc.xml
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
I ended up with:
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
For me, I needed to go File > Project Structure > Modules. Half of my modules had their "module SDK" field set to the wrong thing (not Project Default as they should have been).

NoClassDefFoundError: Unable to run Tycho-built Eclipse RCP application under Linux/Mac OS

I'm developing a cross-platform RCP application in Win 7 (64bit), Indigo/Java 1.6, building the product with Tycho.
While the application runs fine from the Run Configuration within eclipse, and the Win x_86_64 build runs fine as well, I get the following errors on both xubuntu (with OpenJDK Java 6 Runtime (1.6.0_24) and Mac OS X (1.6.0_35).
The error (on Linux) looks like this (running java myprogram):
Exception in thread "main" java.lang.NoClassDefFoundError: myprogram
Caused by: java.lang.ClassNotFoundException: myprogram
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: myprogram. Program will exit.
I'm sure I've come across this before, and I think it was something stupid (this has happened on Windows before AFAIK, and re-installing Java fixed it for some reason). In this case, however, I think it must be to do with the build/target platform/Tycho setup.
The part of my parent POM responsible for the cross-platform build looks unsuspicious enough:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
<!-- configure the p2 target environments for multi-platform build -->
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
Does anybody have any ideas why this might not work?
Many thanks!
This is not how you run an Eclipse RCP application.
You either need to launch it with the appropriate native launcher, or with a java -jar plugins/org.eclipse.equinox.launcher_(yourVersion).jar (see this documentation) and probably further arguments to select your application.
Also, you need to make sure that you have the bundles in your application that Equinox needs to start up. You can do this by including the feature org.eclipse.rcp in you product.

CruiseControl.Net error: Unknown plugin for <msbuild>

I'm trying to get CruiseControl.Net working with MSBuild (this is my first exposure to CruiseControl.Net). I thought I'd done the configuration correctly, however I just get the following error message when starting up:
[cc]Jun-22 20:02:55 Main - error setting config file on controller
net.sourceforge.cruisecontrol.CruiseControlException: error configuring project MyProject
at *SNIP*
Caused by: net.sourceforge.cruisecontrol.CruiseControlException: Unknown plugin for: <msbuild>
at *SNIP*
[cc]Jun-22 20:02:55 Main - error configuring project MyProject
As far as I can work out, this would appear to indicate that I'm missing the MSBuild plugin, however all documentation that I can find indicates that the MSBuild plugin has been included with CruiseControl.Net since version 1.0
I'm using the latest binary release (v 2.8.3)
Here is my config xml:
<project name="MyProject">
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>
<bootstrappers></bootstrappers>
<modificationset quietperiod="10">
<filesystem folder="C:\snip\main"/>
</modificationset>
<schedule interval="60">
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\snip\main</workingDirectory>
<projectFile>MyProject.sln</projectFile>
<buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
<targets>Build;Test</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</schedule>
<log />
<publishers />
</project>
Any advice on how I can troubleshoot this would be much appreciated.
Aggg - it appears that I have unwittingly downloaded CruiseControl, instead of CruiseControl.Net (and to make things even more confusing I was looking at CruiseControl.Net documentation)