Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to run xtext Junit tests outside eclipse
How to run xtext Junit tests outside eclipse [message #1660953] Mon, 09 March 2015 12:10 Go to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
I implemented several tests in the tests plugin in Xtext. I want to run these tests by a command line.
Can anyone help?
Re: How to run xtext Junit tests outside eclipse [message #1660973 is a reply to message #1660953] Mon, 09 March 2015 12:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Just invoke XXXStandaloneSetup.doSetup() and load your *.xxx resources
as normal EMF resources.

Regards

Ed Willink


On 09/03/2015 12:10, Eleanor Richie wrote:
> I implemented several tests in the tests plugin in Xtext. I want to
> run these tests by a command line.
> Can anyone help?
Re: How to run xtext Junit tests outside eclipse [message #1660990 is a reply to message #1660973] Mon, 09 March 2015 12:34 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
I am totally new to Xtext so if you can help me with more steps of how to do this, that will be great Smile
Thanks alot Smile
Re: How to run xtext Junit tests outside eclipse [message #1661034 is a reply to message #1660990] Mon, 09 March 2015 12:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Simply run them as you would do it with normal junit tests
(e.g. using maven tycho surefire)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to run xtext Junit tests outside eclipse [message #1661035 is a reply to message #1661034] Mon, 09 March 2015 12:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
https://github.com/cdietrich/xtext-maven-example

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to run xtext Junit tests outside eclipse [message #1689755 is a reply to message #1661035] Tue, 24 March 2015 08:57 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
I want to run the Junit tests in the MyLang.tests plugins using ANT unfortunately I cant use Maven. any help with that
Re: How to run xtext Junit tests outside eclipse [message #1689811 is a reply to message #1689755] Tue, 24 March 2015 11:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
This should be 100 % straight forward as well

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to run xtext Junit tests outside eclipse [message #1690165 is a reply to message #1689811] Wed, 25 March 2015 14:27 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
I have been working on the ANT build.xml file and succeeded in compiling the junit tests but I am facing a strange error in the junit target. Here is my junit target and the used paths:
<property name="src.dir" value="src"/>
	<path id="junit.class.path">
		<pathelement path="${plugins_dir}/org.junit_4.11.0.v201303080030/junit.jar"/>
		<!-- <pathelement path="${plugins_dir}/org.hamcrest.core_1.3.0.v201303031735.jar"/>-->
		<pathelement path="${plugins_dir}/org.eclipse.emf.common_2.10.1.v20150123-0348.jar"/>
		<pathelement path="${plugins_dir}/org.eclipse.emf.ecore_2.10.2.v20150123-0348.jar"/>
		<pathelement path="${plugins_dir}/org.eclipse.xtext.junit4_2.8.1.v201503230617.jar"/> 
		<pathelement path="${plugins_dir}/org.hamcrest.core_1.3.0.v201303031735.jar"/> 
		<pathelement location="bin"/>
	</path>
	
	<target name="runjunit" depends="compile,delete_logs">
		<junit  printsummary="yes" haltonfailure="no" showoutput="yes" fork="false" >
		  	<test name="my.lang.xtext.LANG.tests.GeneralTestCases" haltonfailure="no" outfile="result">	  		
  		      <formatter type="plain"/>
  		      <formatter type="xml"/>
			</test>
				<classpath refid="junit.class.path">
					<!--<pathelement location="bin"/> -->
			</classpath>
		</junit>
	</target>

In the running of the ANT I got the error of class not found for the Hamcrest plugin so I added it and so other plugins were added as well because they were required. Then the ant gave the below error:

----------------
Type org.eclipse.xtext.junit4.XtextRunner not present
java.lang.TypeNotPresentException: Type org.eclipse.xtext.junit4.XtextRunner not present
at $Proxy4.value(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.xtext.junit4.XtextRunner
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.lang.Class.initAnnotationsIfNecessary(Unknown Source)
at java.lang.Class.getAnnotation(Unknown Source)


-------------------
so I added the org.eclipse.xtext.junit4_2.8.1.v201503230617.jar. The strange thing is that in the run it gave the same error of class not found AGAIN for the HAMCREST although it is already in the pathelement!!! Any clue if there is a connection somehow between xtext.junit4 and the hamcrest? or how can I fix the dependency issue?!

[Updated on: Wed, 25 March 2015 14:27]

Report message to a moderator

Re: How to run xtext Junit tests outside eclipse [message #1690169 is a reply to message #1690165] Wed, 25 March 2015 14:41 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi i cannot help you with that. Using ant you have to manage clasdpath youseft. Maybe you can have a look at a xtext maven example to find out what tycho adds to the classpath

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext refactoring support
Next Topic:cann't reference the instance in jar file or classpath model
Goto Forum:
  


Current Time: Thu Apr 18 19:52:22 GMT 2024

Powered by FUDForum. Page generated in 0.02647 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top