Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Problem using Epsilon Unit Testing Framework(Unit test must failed)
Problem using Epsilon Unit Testing Framework [message #870266] Mon, 07 May 2012 14:03 Go to next message
JM Gauthier is currently offline JM GauthierFriend
Messages: 25
Registered: June 2011
Junior Member
Hello,

I am trying to use EUnit in order to write unit tests for ATL transformation. I have checkout the example (org.eclipse.epsilon.eunit.examples.atl) available on the svn.

This one works fine and the following is shown in the console:

Test compareModel {} passed [cpu: 375 ms, wallclock: 687 ms]
Test root {} passed [cpu: 375 ms, wallclock: 875 ms]
Global result: SUCCESS


But when I modify the file graph-expected.model by adding nodes or changing attributes value, the test is still SUCCESS. This is a problem because I want the oracle and the target model file to be equal in order to have a successfull test.

So, how can I configure .eunit file or eunit.xml to avoid this problem ?

Thanks!

Regards.
Re: Problem using Epsilon Unit Testing Framework [message #870358 is a reply to message #870266] Mon, 07 May 2012 18:53 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

I'm sorry to hear that you're having problems. I've tried doing as you said, but it's working fine on my side:


  1. Import the examples.atl project.
  2. Run the stored launch configuration in "Test Tree2Graph.launch".
  3. SUCCESS (green bar).
  4. Open "models/graph-expected.model", after registering the two EPackages in metamodels.
  5. Add a new Node called "t3", and save.
  6. Run the previous stored launch configuration again.
  7. FAILURE (red bar), because the models are different.


Did you follow those steps, more or less? Is there anything I might have missed?

Which version of Epsilon are you using? Is it the latest interim version, a stable version, or are you running Epsilon straight from SVN?

All that said, I'm running into some issues with unmatched models and being unable to compare the expected and obtained models. I'll look into those as well Smile.

[Updated on: Mon, 07 May 2012 18:53]

Report message to a moderator

Re: Problem using Epsilon Unit Testing Framework [message #870440 is a reply to message #870358] Tue, 08 May 2012 08:44 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

I've just committed a few improvements to EUnit's model comparison tools, (hopefully) fixing the problems with unmatched models and being unable to compare models that are different. However, I haven't run into any issues like yours yet Sad.
Re: Problem using Epsilon Unit Testing Framework [message #870661 is a reply to message #870440] Wed, 09 May 2012 09:24 Go to previous messageGo to next message
JM Gauthier is currently offline JM GauthierFriend
Messages: 25
Registered: June 2011
Junior Member
Hello Antonio,

First of all thank you for your reply and for your time. Smile

I have follow your seven steps but the result is still SUCCESS. I don't see what you might have missed and what I have done wrong...

I am using Eclipse Indigo MDT SR1 and I hope it is a stable version. I have installed Epsilon from the update site download.eclipse.org/epsilon/updates/ and the version is 0.9.1.201107251201.

I hope it could helps Smile.
Re: Problem using Epsilon Unit Testing Framework [message #871319 is a reply to message #870661] Fri, 11 May 2012 22:45 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Thanks, the version was a big hint: it does happen with the latest stable release. I was running Epsilon straight from SVN, so I didn't have your problem.

With the latest interim release, it doesn't do exactly that: instead, it produces an error saying it cannot find the comparator plugin required to integrate EMF Compare into EUnit. It seems we forgot to package the plugin into the Epsilon Core feature Sad. The interim release complained about it, but the stable release simply said "SUCCESS" with no other indication. Sorry about that!

I've gotten it working by removing the stable release (using "Help -> About Eclipse -> Installed Features -> Uninstall..."), installing the latest interim release from http://download.eclipse.org/epsilon/interim/ and then unpacking the attached .zip to the dropins folder of your Eclipse installation. It's the missing plugin from the latest interim release Smile.

You'll probably notice that the "Compare" button is grayed out, and you may get "Unmatched model" exceptions in some circumstances. These issues are fixed in SVN, though.

We'll try to prepare a new interim release as soon as possible with these issues fixed. Thanks for pointing it out!

[Updated on: Fri, 11 May 2012 22:49]

Report message to a moderator

Re: Problem using Epsilon Unit Testing Framework [message #871585 is a reply to message #871319] Mon, 14 May 2012 13:20 Go to previous messageGo to next message
JM Gauthier is currently offline JM GauthierFriend
Messages: 25
Registered: June 2011
Junior Member
Hello Antonio,

I have done what you said and it's working fine now! Smile
Thank you for your help and I'm pleased to have pointed it out, you are welcome.

Regards!
Re: Problem using Epsilon Unit Testing Framework [message #874829 is a reply to message #871585] Mon, 21 May 2012 16:00 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

For the record, we've released a new interim version of Epsilon with the above fix and a few other things. Enjoy! Smile
Re: Problem using Epsilon Unit Testing Framework [message #875842 is a reply to message #874829] Wed, 23 May 2012 12:30 Go to previous messageGo to next message
JM Gauthier is currently offline JM GauthierFriend
Messages: 25
Registered: June 2011
Junior Member
Hello Antonio!

I have updated Epsilon and it seems to work fine! Smile
I have a last question about the use of Epsilon Unit Test.

I would like to do launch several unit tests like that :

@test
operation test1() {
  runTarget("atl_1");
  assertEqualModels("ModelExpected1", "Model1");
}

@test
operation test2() {
  runTarget("atl_2");
  assertEqualModels("ModelExpected2", "Model2");
}


So it's necessary to add a target in the eunit.xml file like the following:

<project>
 <target name="run-tests">
  <epsilon.eunit src="tests/atl.eunit" report="yes">
   <modelTasks>
    <epsilon.emf.loadModel name="MyModel1" modelfile="models/myModel1.sysml" metamodeluri="sysMLUri" read="true" store="false" />
    <epsilon.emf.loadModel name="ModelExpected1" modelfile="models/model_expected_1.model" metamodeluri="myMetamodelUri" read="true" store="false" />
    <epsilon.emf.loadModel name="MyModel2" modelfile="models/myModel2.sysml" metamodeluri="sysMLUri" read="true" store="false" />
    <epsilon.emf.loadModel name="ModelExpected2" modelfile="models/model_expected_2.model" metamodeluri="myMetamodelUri" read="true" store="false" />
   </modelTasks>
  </epsilon.eunit>
 </target>
	
 <target name="atl_1">
  
  <tempfile property="atl.temp.srcfile" />
  <tempfile property="atl.temp.dstfile" />
  <epsilon.storeModel model="MyModel1" target="${atl.temp.srcfile}" />
  <atl.loadModel name="MMsysml" metamodel="MOF" uri="sysMLUri" />
  <atl.loadModel name="MMModel" metamodel="MOF" uri="myMetamodelUri" />
  <atl.loadModel name="MyModel1" metamodel="MMsysml" path="${atl.temp.srcfile}" />
  
  <atl.launch path="sysml2model.atl">
   <inmodel name="INsysml" model="MyModel1" />
   <outmodel name="OUT" model="Model1" metamodel="MMModel" />
  </atl.launch>
  <atl.saveModel model="Model1" path="${atl.temp.dstfile}" />
  <epsilon.emf.loadModel name="Model1" modelfile="${atl.temp.dstfile}" metamodeluri="myMetamodelUri" read="true" store="false" />

  <delete file="${atl.temp.srcfile}" />
  <delete file="${atl.temp.dstfile}" />

 </target>
	
 <target name="atl_2">
  
  <tempfile property="atl.temp.srcfile" />
  <tempfile property="atl.temp.dstfile" />
  <epsilon.storeModel model="MyModel2" target="${atl.temp.srcfile}" />
  <atl.loadModel name="MMsysml" metamodel="MOF" uri="sysMLUri" />
  <atl.loadModel name="MMModel" metamodel="MOF" uri="myMetamodelUri" />
  <atl.loadModel name="MyModel2" metamodel="MMsysml" path="${atl.temp.srcfile}" />
  
  <atl.launch path="sysml2model.atl">
   <inmodel name="INsysml" model="MyModel2" />
   <outmodel name="OUT" model="Model2" metamodel="MMModel" />
  </atl.launch>
  <atl.saveModel model="Model2" path="${atl.temp.dstfile}" />
  <epsilon.emf.loadModel name="Model2" modelfile="${atl.temp.dstfile}" metamodeluri="myMetamodelUri" read="true" store="false" />

  <delete file="${atl.temp.srcfile}" />
  <delete file="${atl.temp.dstfile}" />
 </target>
	
</project>



So I have two targets to launch. The problem is that the second unit test always fail because the temp files are deleted only when the operation is finished. It means that it is the same temp files for target atl_1 and atl_2.

Is it normal ? I probably don't do this correctly, so what is the best way to launch several unit tests with several model (one model per unit test) ?

Thank you again!

Regards.
Re: Problem using Epsilon Unit Testing Framework [message #875972 is a reply to message #875842] Wed, 23 May 2012 16:36 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

The problem is that Ant properties are always global and immutable: once you set a value, they're frozen for the rest of the tests. A quick fix would be to use different property names for the atl_1 and atl_2 tasks.

There are quite a few ways to run the same tests for different sets of models in EUnit. I would suggest using EUnit's $with annotation, as it's very powerful: it allows you to repeat the same test with different sets of models. To use it, the models need to be available before EUnit is started, though, so you'd need to run the ATL transformations before launching EUnit.

To avoid copying and pasting the same fragment over and over, I'd suggest that you look into the <macrodef> Ant task to define your own reusable Ant task for running your ATL transformation.

Your eunit.xml file could look like this (untested, sorry!):

<project>
  <target name="run-tests" depends="init-atl">
    <runATL srcfile="models/myModel1.sysml" srcmodel="MyModel1" dstmodel="Model1"/>
    <runATL srcfile="models/myModel1.sysml" srcmodel="MyModel2" dstmodel="Model2"/>

    <epsilon.emf.loadModel name="ModelExpected1"
        modelfile="models/model_expected_1.model"
        metamodeluri="myMetamodelUri"
        read="true" store="false" />
    <epsilon.emf.loadModel name="ModelExpected2"
        modelfile="models/model_expected_2.model"
        metamodeluri="myMetamodelUri"
        read="true" store="false" />

    <epsilon.eunit src="tests/atl.eunit" report="yes">
      <model ref="MyModel1"/>
      <model ref="MyModel2"/>
      <model ref="Model1"/>
      <model ref="Model2"/>
      <model ref="ModelExpected1"/>
      <model ref="ModelExpected2"/>
    </epsilon.eunit>
  </target>
	
  <target name="init-atl">
    <atl.loadModel name="MMsysml" metamodel="MOF" uri="sysMLUri" />
    <atl.loadModel name="MMModel" metamodel="MOF" uri="myMetamodelUri" />
    <macrodef name="runATL">
       <attribute name="srcfile"/>
       <attribute name="srcmodel"/>
       <attribute name="dstmodel"/>
       <sequential>
         <epsilon.emf.loadModel name="@{srcmodel}"
            modelfile="@{srcfile}"
            metamodeluri="myMetamodelUri"
            read="true" store="false" />
  
         <atl.loadModel name="@{srcmodel}" metamodel="MMsysml" path="@{srcfile}"/>
  
         <atl.launch path="sysml2model.atl">
           <inmodel name="INsysml" model="@{srcmodel}" />
           <outmodel name="OUT" model="@{dstmodel}" metamodel="MMModel" />
         </atl.launch>

         <atl.saveModel model="@{dstmodel}" path="@{srcfile}.tmpdst.model" />
         <epsilon.emf.loadModel name="@{dstmodel}" modelfile="@{srcfile}.tmpdst.model"
           metamodeluri="myMetamodelUri" read="true" store="false" />

        <delete file="@{srcfile}.tmpdst.model"/>
      </sequential>
    </macrodef>
  </target>
</project>	


With that, you'd avoid quite a bit of repetition, and your .eunit file could be shortened to:

$with Map {"Expected" = "ModelExpected1", "Obtained" = "Model1" }
$with Map {"Expected" = "ModelExpected2", "Obtained" = "Model2" }
@test
operation test1() {
  assertEqualModels("Expected", "Obtained");
}

Re: Problem using Epsilon Unit Testing Framework [message #878440 is a reply to message #875972] Tue, 29 May 2012 10:00 Go to previous message
JM Gauthier is currently offline JM GauthierFriend
Messages: 25
Registered: June 2011
Junior Member
Hello Antonio!

Thank you for your reply and for your help. I will try this.

Well thank you again!

Regards.
Previous Topic:Forcing an new line EGL
Next Topic:Method 'satisfiesOne' not found for ...
Goto Forum:
  


Current Time: Fri Apr 19 14:22:09 GMT 2024

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

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

Back to the top