Skip to main content



      Home
Home » Modeling » TMF (Xtext) » XPECT testing(XPECT testing for Xtext Grammar)
icon5.gif  XPECT testing [message #1112360] Thu, 19 September 2013 09:44 Go to next message
Eclipse UserFriend
Hello all,
I am using xpect testing for my dsl testing.
I want to write a method in my java file, say to return "Hello".

And in my xpect file, say someName.dsl.xt
I want to call this java method, which should replace function call with "Hello" in my xpect file.

Is it possible ??


Thanks in advance Smile

Regards,
Arshad
Re: XPECT testing [message #1114808 is a reply to message #1112360] Mon, 23 September 2013 04:28 Go to previous message
Eclipse UserFriend
Hi Arshad,

I recently blogged about Xpect, see: http://blog.moritz.eysholdt.de/2013/09/introduction-to-xpect.html

I'm not completely sure I understand what you have in mind. But here is some sketch, let me know how close it gets to what you imagined:

someName.dsl.xt
// XPECT_SETUP mypackage.MyJavaTest END_SETUP

// XPECT myTestMethod --> Hello Berlin


MyJavaTest.java
package mypackage;
class MyJavaTest {
  public void myTestMethod(@StringExpectation IStringExpectation expectation) {
    expectation.assertEqual("Hello Kiel")
  }
}


If you run this test, the file someName.dsl.xt will invoke the method myTestMethod() from the Java class. The part after the "-->" will passed in as expectation. Consequently, the assertEqual fails because "Hello Berlin" does not equal "Hello Kiel". You can double-click on the failed test to open the comparison editor to compare/edit the failed expectation.

[Updated on: Mon, 23 September 2013 04:32] by Moderator

Previous Topic:URIImport of a non-xtext resource and referencing of its declared objects
Next Topic:AST always getting generated despite errors
Goto Forum:
  


Current Time: Sun Jul 20 15:01:50 EDT 2025

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

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

Back to the top