Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generated tests from EMF
Generated tests from EMF [message #662581] Thu, 31 March 2011 08:35 Go to next message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

We can generated unit tests for our EMF model. When i look at these tests most of them are empty blocks.
What is the real purpose of these tests ?
Have someone used these generated tests ? Can you share your experience by this feature ?

Regards,
Ashwani Kr Sharma
Re: Generated tests from EMF [message #662703 is a reply to message #662581] Thu, 31 March 2011 15:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
Ashwani,

Comments below.

Ashwani Kr Sharma wrote:
> Hi,
>
> We can generated unit tests for our EMF model. When i look at these
> tests most of them are empty blocks.
> What is the real purpose of these tests ?
They're scaffolding in which you can write meaningful tests.
> Have someone used these generated tests ? Can you share your
> experience by this feature ?
The UML2 project has used them. So you might look at their source.

Think about it though... If you have a well formed model, EMF always
generated a correct implementation of it. There's really nothing to
test. If there were tests that failed, we'd have to fix the generator
so they didn't. The only things that need testing is the code that you
add yourself to the generated classes. As you add such code, you should
write the tests to validate and confirm correct expected behavior.
>
> Regards,
> Ashwani Kr Sharma
Re: Generated tests from EMF [message #663060 is a reply to message #662703] Sat, 02 April 2011 21:32 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 233
Registered: July 2009
Senior Member
Ed,

Why is then that all generated test end up with:
// TODO: implement this operation test method
// Ensure that you remove @generated or mark it @generated NOT
fail();

which by default causes hundreds of failures. What we would want is the
for the default to do nothing, just put a TODO and we can implement only
the tests we care about and still get the scaffolding generated.

Or am I missing something obvious?

Cheers,
Alain

On 3/31/2011 11:43 AM, Ed Merks wrote:
> Ashwani,
>
> Comments below.
>
> Ashwani Kr Sharma wrote:
>> Hi,
>>
>> We can generated unit tests for our EMF model. When i look at these
>> tests most of them are empty blocks.
>> What is the real purpose of these tests ?
> They're scaffolding in which you can write meaningful tests.
>> Have someone used these generated tests ? Can you share your
>> experience by this feature ?
> The UML2 project has used them. So you might look at their source.
>
> Think about it though... If you have a well formed model, EMF always
> generated a correct implementation of it. There's really nothing to
> test. If there were tests that failed, we'd have to fix the generator so
> they didn't. The only things that need testing is the code that you add
> yourself to the generated classes. As you add such code, you should
> write the tests to validate and confirm correct expected behavior.
>>
>> Regards,
>> Ashwani Kr Sharma
Re: Generated tests from EMF [message #663061 is a reply to message #663060] Sat, 02 April 2011 23:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
Alain,

Presumably all operations do something meaningful/useful that's worth
testing. That's the assumption we're making...


Alain Picard wrote:
> Ed,
>
> Why is then that all generated test end up with:
> // TODO: implement this operation test method
> // Ensure that you remove @generated or mark it @generated NOT
> fail();
>
> which by default causes hundreds of failures. What we would want is
> the for the default to do nothing, just put a TODO and we can
> implement only the tests we care about and still get the scaffolding
> generated.
>
> Or am I missing something obvious?
>
> Cheers,
> Alain
>
> On 3/31/2011 11:43 AM, Ed Merks wrote:
>> Ashwani,
>>
>> Comments below.
>>
>> Ashwani Kr Sharma wrote:
>>> Hi,
>>>
>>> We can generated unit tests for our EMF model. When i look at these
>>> tests most of them are empty blocks.
>>> What is the real purpose of these tests ?
>> They're scaffolding in which you can write meaningful tests.
>>> Have someone used these generated tests ? Can you share your
>>> experience by this feature ?
>> The UML2 project has used them. So you might look at their source.
>>
>> Think about it though... If you have a well formed model, EMF always
>> generated a correct implementation of it. There's really nothing to
>> test. If there were tests that failed, we'd have to fix the generator so
>> they didn't. The only things that need testing is the code that you add
>> yourself to the generated classes. As you add such code, you should
>> write the tests to validate and confirm correct expected behavior.
>>>
>>> Regards,
>>> Ashwani Kr Sharma
>
Re: Generated tests from EMF [message #663093 is a reply to message #663061] Sun, 03 April 2011 14:20 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 233
Registered: July 2009
Senior Member
Why not just like the unimplemented method, throw a
NotImplementedException(), the difference would be clearer.

Alain

On 4/2/2011 7:19 PM, Ed Merks wrote:
> Alain,
>
> Presumably all operations do something meaningful/useful that's worth
> testing. That's the assumption we're making...
>
>
> Alain Picard wrote:
>> Ed,
>>
>> Why is then that all generated test end up with:
>> // TODO: implement this operation test method
>> // Ensure that you remove @generated or mark it @generated NOT
>> fail();
>>
>> which by default causes hundreds of failures. What we would want is
>> the for the default to do nothing, just put a TODO and we can
>> implement only the tests we care about and still get the scaffolding
>> generated.
>>
>> Or am I missing something obvious?
>>
>> Cheers,
>> Alain
>>
>> On 3/31/2011 11:43 AM, Ed Merks wrote:
>>> Ashwani,
>>>
>>> Comments below.
>>>
>>> Ashwani Kr Sharma wrote:
>>>> Hi,
>>>>
>>>> We can generated unit tests for our EMF model. When i look at these
>>>> tests most of them are empty blocks.
>>>> What is the real purpose of these tests ?
>>> They're scaffolding in which you can write meaningful tests.
>>>> Have someone used these generated tests ? Can you share your
>>>> experience by this feature ?
>>> The UML2 project has used them. So you might look at their source.
>>>
>>> Think about it though... If you have a well formed model, EMF always
>>> generated a correct implementation of it. There's really nothing to
>>> test. If there were tests that failed, we'd have to fix the generator so
>>> they didn't. The only things that need testing is the code that you add
>>> yourself to the generated classes. As you add such code, you should
>>> write the tests to validate and confirm correct expected behavior.
>>>>
>>>> Regards,
>>>> Ashwani Kr Sharma
>>
Re: Generated tests from EMF [message #663094 is a reply to message #663093] Sun, 03 April 2011 14:24 Go to previous messageGo to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 233
Registered: July 2009
Senior Member
Sorry, meant: UnsupportedOperationException()

Alain

On 4/3/2011 10:20 AM, Alain Picard wrote:
> Why not just like the unimplemented method, throw a
> NotImplementedException(), the difference would be clearer.
>
> Alain
>
> On 4/2/2011 7:19 PM, Ed Merks wrote:
>> Alain,
>>
>> Presumably all operations do something meaningful/useful that's worth
>> testing. That's the assumption we're making...
>>
>>
>> Alain Picard wrote:
>>> Ed,
>>>
>>> Why is then that all generated test end up with:
>>> // TODO: implement this operation test method
>>> // Ensure that you remove @generated or mark it @generated NOT
>>> fail();
>>>
>>> which by default causes hundreds of failures. What we would want is
>>> the for the default to do nothing, just put a TODO and we can
>>> implement only the tests we care about and still get the scaffolding
>>> generated.
>>>
>>> Or am I missing something obvious?
>>>
>>> Cheers,
>>> Alain
>>>
>>> On 3/31/2011 11:43 AM, Ed Merks wrote:
>>>> Ashwani,
>>>>
>>>> Comments below.
>>>>
>>>> Ashwani Kr Sharma wrote:
>>>>> Hi,
>>>>>
>>>>> We can generated unit tests for our EMF model. When i look at these
>>>>> tests most of them are empty blocks.
>>>>> What is the real purpose of these tests ?
>>>> They're scaffolding in which you can write meaningful tests.
>>>>> Have someone used these generated tests ? Can you share your
>>>>> experience by this feature ?
>>>> The UML2 project has used them. So you might look at their source.
>>>>
>>>> Think about it though... If you have a well formed model, EMF always
>>>> generated a correct implementation of it. There's really nothing to
>>>> test. If there were tests that failed, we'd have to fix the
>>>> generator so
>>>> they didn't. The only things that need testing is the code that you add
>>>> yourself to the generated classes. As you add such code, you should
>>>> write the tests to validate and confirm correct expected behavior.
>>>>>
>>>>> Regards,
>>>>> Ashwani Kr Sharma
>>>
>
Re: Generated tests from EMF [message #663105 is a reply to message #663093] Sun, 03 April 2011 16:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
Alain,

Wouldn't that just produce a different kind of failure? It's not
obvious to me why that kind of failure would be better or more clear.
Certainly a TODO automatically produces markers that are designed to
call attention to things that need to be done...


Alain Picard wrote:
> Why not just like the unimplemented method, throw a
> NotImplementedException(), the difference would be clearer.
>
> Alain
>
> On 4/2/2011 7:19 PM, Ed Merks wrote:
>> Alain,
>>
>> Presumably all operations do something meaningful/useful that's worth
>> testing. That's the assumption we're making...
>>
>>
>> Alain Picard wrote:
>>> Ed,
>>>
>>> Why is then that all generated test end up with:
>>> // TODO: implement this operation test method
>>> // Ensure that you remove @generated or mark it @generated NOT
>>> fail();
>>>
>>> which by default causes hundreds of failures. What we would want is
>>> the for the default to do nothing, just put a TODO and we can
>>> implement only the tests we care about and still get the scaffolding
>>> generated.
>>>
>>> Or am I missing something obvious?
>>>
>>> Cheers,
>>> Alain
>>>
>>> On 3/31/2011 11:43 AM, Ed Merks wrote:
>>>> Ashwani,
>>>>
>>>> Comments below.
>>>>
>>>> Ashwani Kr Sharma wrote:
>>>>> Hi,
>>>>>
>>>>> We can generated unit tests for our EMF model. When i look at these
>>>>> tests most of them are empty blocks.
>>>>> What is the real purpose of these tests ?
>>>> They're scaffolding in which you can write meaningful tests.
>>>>> Have someone used these generated tests ? Can you share your
>>>>> experience by this feature ?
>>>> The UML2 project has used them. So you might look at their source.
>>>>
>>>> Think about it though... If you have a well formed model, EMF always
>>>> generated a correct implementation of it. There's really nothing to
>>>> test. If there were tests that failed, we'd have to fix the
>>>> generator so
>>>> they didn't. The only things that need testing is the code that you
>>>> add
>>>> yourself to the generated classes. As you add such code, you should
>>>> write the tests to validate and confirm correct expected behavior.
>>>>>
>>>>> Regards,
>>>>> Ashwani Kr Sharma
>>>
>
Re: Generated tests from EMF [message #663135 is a reply to message #663105] Mon, 04 April 2011 00:03 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 233
Registered: July 2009
Senior Member
IMHO it would make it a bit easier to discern what is a test failure vs.
a non implementation.

Alain

On 4/3/2011 12:36 PM, Ed Merks wrote:
> Alain,
>
> Wouldn't that just produce a different kind of failure? It's not obvious
> to me why that kind of failure would be better or more clear. Certainly
> a TODO automatically produces markers that are designed to call
> attention to things that need to be done...
>
>
> Alain Picard wrote:
>> Why not just like the unimplemented method, throw a
>> NotImplementedException(), the difference would be clearer.
>>
>> Alain
>>
>> On 4/2/2011 7:19 PM, Ed Merks wrote:
>>> Alain,
>>>
>>> Presumably all operations do something meaningful/useful that's worth
>>> testing. That's the assumption we're making...
>>>
>>>
>>> Alain Picard wrote:
>>>> Ed,
>>>>
>>>> Why is then that all generated test end up with:
>>>> // TODO: implement this operation test method
>>>> // Ensure that you remove @generated or mark it @generated NOT
>>>> fail();
>>>>
>>>> which by default causes hundreds of failures. What we would want is
>>>> the for the default to do nothing, just put a TODO and we can
>>>> implement only the tests we care about and still get the scaffolding
>>>> generated.
>>>>
>>>> Or am I missing something obvious?
>>>>
>>>> Cheers,
>>>> Alain
>>>>
>>>> On 3/31/2011 11:43 AM, Ed Merks wrote:
>>>>> Ashwani,
>>>>>
>>>>> Comments below.
>>>>>
>>>>> Ashwani Kr Sharma wrote:
>>>>>> Hi,
>>>>>>
>>>>>> We can generated unit tests for our EMF model. When i look at these
>>>>>> tests most of them are empty blocks.
>>>>>> What is the real purpose of these tests ?
>>>>> They're scaffolding in which you can write meaningful tests.
>>>>>> Have someone used these generated tests ? Can you share your
>>>>>> experience by this feature ?
>>>>> The UML2 project has used them. So you might look at their source.
>>>>>
>>>>> Think about it though... If you have a well formed model, EMF always
>>>>> generated a correct implementation of it. There's really nothing to
>>>>> test. If there were tests that failed, we'd have to fix the
>>>>> generator so
>>>>> they didn't. The only things that need testing is the code that you
>>>>> add
>>>>> yourself to the generated classes. As you add such code, you should
>>>>> write the tests to validate and confirm correct expected behavior.
>>>>>>
>>>>>> Regards,
>>>>>> Ashwani Kr Sharma
>>>>
>>
Previous Topic:[CDO] CDOMergingConflictResolver in action
Next Topic:[CDO] IllegalStateException: Not able to update container columns of CDOResource with id OID:http://
Goto Forum:
  


Current Time: Wed Oct 23 15:33:53 GMT 2019

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

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

Back to the top