Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EUnit] - Some thoughts and considerations about mode testing with EUnit(Testing generated models (model implementation))
[EUnit] - Some thoughts and considerations about mode testing with EUnit [message #877387] Sat, 26 May 2012 16:28 Go to next message
Samir Al-Hilank is currently offline Samir Al-HilankFriend
Messages: 4
Registered: November 2011
Junior Member
Hi everybody,

i am currently developing an emf model that is a little more complex. It provides a set of operations, properties, derived values etc. that have been implemented into the generated code. Now I would like to test the implementation by using EUnit which I found very good for model testing. Everything is fine as long as I am using the .ecore file as metamodel definition. I could of course start a new eclipse application that registers the implementation of the metamodel. But that is a rather heavy-weight and time consuming process and I would have to restart the application in case of implementation changes (which happens often in test-develop-cycles)...

Has anyone experiences with similar use cases? Is there a way to register (and update) the implementation into the "running" eclipse / epsilon framework (in the context of a test run) without mixing up the EMF Registry?

Digging into some details Wink with respect to a using a pure java setup with EUnit

I tried to use the epsilon ant tasks in a pure java environment but there seem to be dependencies to the eclipse (UI?) and the EUnit task did not work. I also recognized that the epsilontask.xml file in epsilon.workflow seems to lack some tasks (e.g. epsilon.emf.loadmodel). Also there seems to be a typing error in epsilontask.xml: I did not find an ant task named "org.eclipse.epsilon.workflow.tasks.LoadCompositeModel" but one that is named "org.eclipse.epsilon.workflow.tasks.LoadCompositeModelTask" (seems to me that "Task" postfix is missing). This leads to ant not being able to resolve all necessary task dependencies. Currently I use a workaround: good old taskdefs pointing to the required tasks. The tests itself are then executed in a pure java environment and I register the emf metamodel - works, but that somehow contradicts the workflow that is realized by the nice EUnit UI integration into eclipse Sad...

I also observed that the assertEquals(...)-statements do not print the expected and actual value that is a very valueable information when inspecting the test results... But perhaps here I am doing something wrong...

By the way I also used your HUTN-Implementation and wrote an ant task that transforms HUTN-files into emf models and used them as test input data. I did not find a way to supply a HUTN-File to the ant tasks that would really be a cool enhancement (Separation of test data from the actual test coding)... The HUTN implementation saved me a lot of time and worked superb!

Thanks!

Cheers

Samir
Re: [EUnit] - Some thoughts and considerations about mode testing with EUnit [message #877681 is a reply to message #877387] Sun, 27 May 2012 11:41 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 309
Registered: January 2010
Senior Member
Hi Samir,

Thanks for all your feedback!

Samir Al-Hilank wrote on Sat, 26 May 2012 12:28

i am currently developing an emf model that is a little more complex. It provides a set of operations, properties, derived values etc. that have been implemented into the generated code. Now I would like to test the implementation by using EUnit which I found very good for model testing. Everything is fine as long as I am using the .ecore file as metamodel definition. I could of course start a new eclipse application that registers the implementation of the metamodel. But that is a rather heavy-weight and time consuming process and I would have to restart the application in case of implementation changes (which happens often in test-develop-cycles)...

Has anyone experiences with similar use cases? Is there a way to register (and update) the implementation into the "running" eclipse / epsilon framework (in the context of a test run) without mixing up the EMF Registry?


We provide an Ant task for registering a metamodel. Have you tried it?

<epsilon.emf.register permanently="false" file="your-metamodel.ecore"/>


Samir Al-Hilank wrote on Sat, 26 May 2012 12:28

Digging into some details Wink with respect to a using a pure java setup with EUnit

I tried to use the epsilon ant tasks in a pure java environment but there seem to be dependencies to the eclipse (UI?) and the EUnit task did not work.


Yes, until recently, EUnit could not run in a headless setup (without the Eclipse workbench). This has been fixed, though (see comment 4 for installation instructions):

https://bugs.eclipse.org/bugs/show_bug.cgi?id=379699

Samir Al-Hilank wrote on Sat, 26 May 2012 12:28

I also recognized that the epsilontask.xml file in epsilon.workflow seems to lack some tasks (e.g. epsilon.emf.loadmodel). Also there seems to be a typing error in epsilontask.xml: I did not find an ant task named "org.eclipse.epsilon.workflow.tasks.LoadCompositeModel" but one that is named "org.eclipse.epsilon.workflow.tasks.LoadCompositeModelTask" (seems to me that "Task" postfix is missing). This leads to ant not being able to resolve all necessary task dependencies. Currently I use a workaround: good old taskdefs pointing to the required tasks.


Oops, sorry about that. I've just committed some changes to epsilontasks.xml adding the missing tasks and fixing the problem you mention. I've added a test as well, to catch this sort of thing in the future.

Samir Al-Hilank wrote on Sat, 26 May 2012 12:28

The tests itself are then executed in a pure java environment and I register the emf metamodel - works, but that somehow contradicts the workflow that is realized by the nice EUnit UI integration into eclipse Sad...


How would you like it to work? If it's just being able to run the Ant task in a headless environment, it's been fixed recently - see above.

Samir Al-Hilank wrote on Sat, 26 May 2012 12:28

I also observed that the assertEquals(...)-statements do not print the expected and actual value that is a very valueable information when inspecting the test results... But perhaps here I am doing something wrong...


That's odd. How are you calling the assertEquals statements, exactly?

Samir Al-Hilank wrote on Sat, 26 May 2012 12:28

By the way I also used your HUTN-Implementation and wrote an ant task that transforms HUTN-files into emf models and used them as test input data. I did not find a way to supply a HUTN-File to the ant tasks that would really be a cool enhancement (Separation of test data from the actual test coding)... The HUTN implementation saved me a lot of time and worked superb!


I'm glad you found HUTN useful! Patches are welcome, by the way Wink.

I recall that EUnit has a loadHutn method for loading models quickly fom the test suite. Did you try that?

Cheers,
Antonio
Re: [EUnit] - Some thoughts and considerations about mode testing with EUnit [message #878456 is a reply to message #877387] Tue, 29 May 2012 10:46 Go to previous messageGo to next message
Samir Al-Hilank is currently offline Samir Al-HilankFriend
Messages: 4
Registered: November 2011
Junior Member
Hi Antonio,


  1. Regarding ant issues

    thanks for your detailed feedback. I will get the latest version of epsilon, build it and try it again...

  2. Regarding model registration

    The snippet you posted is used for registering the meta model based on an ecore file. The problem in my use case is that I don't want to use the file based meta model approach - I want to use the generated EPackage-Registry along with the generated classes... And here I am a little lost... Currently I start a new eclipse instance for testing that has my implementation registered (EMF generated package registry). But I have to restart it in case of implementation changes made to the model code... That solution does of course work - but perhaps a better, more lightweight approach (two full blown eclipse development instances are quite resource hungry) is known... Wink

    By the way what is the meaning of "permanent=false" in the emf.register task? Seems that I have overseen a feature...

  3. AssertEquals

    Here is a small snippet from a test method that I have used:

    @test
    operation ts0201_tc02() {
    	AssertEquals("Failure", 1, 2);
    }
    


    I did run EUnit via an ant task (inside eclipse) ant the following result is shown in EUnit view:
    org.eclipse.epsilon.eol.exceptions.EolAssertionException: Failure (L:\...)
    


    Perhaps I am looking at the wrong place?


  4. HUTN

    Yes, there is a method that loads a hutn-String. But as far as I know there is no possibility to supply a path that points to a file containing the HUTN-source. If I find some time next week I can refactor my HUTN ant task to extend from EpsilonTask and provide a patch for that - if there is a chance to integrate that into Epsilon Smile.



Again thanks for the feedback!

Cheers!

Samir




Re: [EUnit] - Some thoughts and considerations about mode testing with EUnit [message #889896 is a reply to message #878456] Wed, 20 June 2012 07:51 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 309
Registered: January 2010
Senior Member
Oops, I lost track of this thread. Sorry for the late reply!

Samir Al-Hilank wrote on Tue, 29 May 2012 06:46
Hi Antonio,
[*] Regarding model registration

The snippet you posted is used for registering the meta model based on an ecore file. The problem in my use case is that I don't want to use the file based meta model approach - I want to use the generated EPackage-Registry along with the generated classes... And here I am a little lost... Currently I start a new eclipse instance for testing that has my implementation registered (EMF generated package registry). But I have to restart it in case of implementation changes made to the model code... That solution does of course work - but perhaps a better, more lightweight approach (two full blown eclipse development instances are quite resource hungry) is known... Wink


Yes, I have to work with three Eclipse instances every day (Epsilon -> metamodels -> models), and it's not pretty either Smile. You could speed up your tests by not bringing a full-blown workspace, but doing a headless build instead. Have a look at the "Program to Run" section here:

http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Flaunchers%2Fjunit_main.htm

If EUnit doesn't work in headless mode, please report the bug and post a link in this thread Smile.

Samir Al-Hilank wrote on Tue, 29 May 2012 06:46
Hi Antonio,
By the way what is the meaning of "permanent=false" in the emf.register task? Seems that I have overseen a feature...


It only registers the metamodel for the duration of that Ant build. Once the build is over, it won't be available any more.

Quote:

Here is a small snippet from a test method that I have used:

@test
operation ts0201_tc02() {
	AssertEquals("Failure", 1, 2);
}



It's "assertEquals", not "AssertEquals" Smile.

Quote:

Yes, there is a method that loads a hutn-String. But as far as I know there is no possibility to supply a path that points to a file containing the HUTN-source. If I find some time next week I can refactor my HUTN ant task to extend from EpsilonTask and provide a patch for that - if there is a chance to integrate that into Epsilon Smile.


Sure! Please attach it to an enhancement request and post it here. We'll give it a look and integrate it if it looks good Smile.

Cheers,
Antonio
Previous Topic:No vaiable alternative at input 'default'
Next Topic:[EWL] Wizards is not appearing in RCP Application
Goto Forum:
  


Current Time: Mon Nov 24 08:40:03 GMT 2014

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

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