Re: Test that fail randomly with wounit
Re: Test that fail randomly with wounit
- Subject: Re: Test that fail randomly with wounit
- From: Samuel Pelletier <email@hidden>
- Date: Tue, 18 Jun 2013 19:43:43 -0400
Hi Chuck,
> Hi Samuel,
>
> JUnit can/will run tests in a different order each time. So if your tests depend on something else having happened (EOF getting fully initialized, some other test running first) you will see random failures like this. I think it an/will run tests in multiple threads too (I use both JUnit and TestNG and sometimes mix up their features :-) so concurrency can also cause problems like this.
I was wondering a multiple test side effect and build a single test class to verify and the situation is still there (I put the complete class except import and static final declarations in my previous message).
I suspect some concurrency problem but where is the concurrency with a single test running? Even the debugger see only one thread.
>>
>> I have a test that succeed sometime and fail other times. If I run the jUnit source that contain this test, it fail sometime in the loadPermission() method. I have no idea where to look at. It is even more strange that sometime, I can have 6 successful tests and after 4 failed in a row.
>>
>> These test are inside a framework project. When I run the tests, I have these lines on the console but they do not seems to cause problem with the about 100 others tests in the project.
>>
>> - The EOModel 'erprototypes' has an empty connection dictionary.
>> - The EOModel 'erprototypes' has an empty connection dictionary.
>
> Those are likely to be OK.
>
>> - The EOModel 'KAAccessControl' has an empty connection dictionary.
>> - The EOModel 'KAAccessControl' has an empty connection dictionary.
>
> I am guessing you need that model for the permissions testing. This is likely a problem.
>
>> - The model 'KAAccessControl' (path: file:/Users/sam/work/KavijuWO/KAAccessControl/Resources/KAAccessControl.eomodeld) cannot be added to model group <EOModelGroup (("KAAccessControl", "file:/Users/sam/work/KavijuWO/KAAccessControl/Resources/KAAccessControl.eomodeld"), ("erprototypes", "file:/Users/sam/work/WonderSource/Frameworks/Core/ERPrototypes/Resources/erprototypes.eomodeld"))> because it already contains a model with that name.
>>
>> Any idea?
>
> Do you have multiple EOF stacks (multiple EOObjectStoreCoordinators)? You could be using default* methods that only work with the default stack. Is there a stack trace for that last one to show where duplication model loading is having?
I added dummy connection information in the model and the 2 empty connection dictionary warning for KAAccessControl disappeared but not the "… already contains a model with that name." warning. Those are printed during the MockEditingContext creation. I have no idea that explain why the warning are duplicated.
I do not use multiple EOF stack and anyway in the context of running the test, everything is from the sole MockEditingContext defined in the test class.
The NPE is raised on the first EOUtilities.createAndInsertInstance() call sometime.
Samuel
>
>
>>
>> Samuel
>>
>> RolesFileLoader load a plist file to create and update objects in the database.
>>
>> Here is a my test source with a single test:
>>
>> @Rule public MockEditingContext ec = new MockEditingContext();
>>
>> @Before
>> public void loadPermissions() {
>> ERXProperties.setStringForKey("SampleRolesFile", RolesFileLoader.rolesFileNamePropertyKey);
>> RolesFileLoader.loadRolesFile(ec);
>> }
>>
>> @Test
>> public void testReloadPermissions() {
>> ERXProperties.setStringForKey("SampleRolesFile", RolesFileLoader.rolesFileNamePropertyKey);
>> RolesFileLoader.loadRolesFile(ec);
>> }
>>
>> The error stack:
>>
>> com.webobjects.foundation.NSForwardException [java.lang.reflect.InvocationTargetException] null:java.lang.reflect.InvocationTargetException
>> …
>> Caused by: java.lang.reflect.InvocationTargetException
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>> at com.webobjects.foundation._NSUtilities.instantiateObjectWithConstructor(_NSUtilities.java:659)
>> ... 32 more
>> Caused by: java.lang.NullPointerException
>> at com.webobjects.eoaccess.EOModel.createPrototypeCache(EOModel.java:631)
>
> I think that means a model is being used that is not yet in an EOModelGroup.
>
>
> Chuck
>
>> at com.webobjects.eoaccess.EOModel.prototypeAttributeNamed(EOModel.java:699)
>> at com.webobjects.eoaccess.ERXModel.prototypeAttributeNamed(ERXModel.java:290)
>> at com.webobjects.eoaccess.EOAttribute.<init>(EOAttribute.java:998)
>> at com.webobjects.eoaccess.EOEntity.attributes(EOEntity.java:816)
>> at com.webobjects.eoaccess.EOEntity.attributeNamed(EOEntity.java:789)
>> at com.webobjects.eoaccess.EOEntity.classProperties(EOEntity.java:1098)
>> at com.webobjects.eoaccess.EOEntity._propertyDictionaryInitializer(EOEntity.java:3321)
>> at com.webobjects.eoaccess.EOEntity._newDictionaryForProperties(EOEntity.java:3667)
>> at com.webobjects.eoaccess.EOEntityClassDescription._newDictionaryForProperties(EOEntityClassDescription.java:88)
>> at com.webobjects.eocontrol.EOGenericRecord.__setClassDescription(EOGenericRecord.java:111)
>> at com.webobjects.eocontrol.EOGenericRecord.__setClassDescription(EOGenericRecord.java:100)
>> at com.webobjects.eocontrol.EOGenericRecord.<init>(EOGenericRecord.java:73)
>> at er.extensions.eof.ERXGenericRecord.<init>(ERXGenericRecord.java:106)
>> at com.kaviju.accesscontrol.model.base._KAAccessList.<init>(_KAAccessList.java:15)
>> at com.kaviju.accesscontrol.model.KAAccessList.<init>(KAAccessList.java:8)
>> ... 37 more
>
> --
> Chuck Hill
> Executive Managing Partner, VP Development and Technical Services
>
> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/gvc/practical_webobjects
>
> Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
>
> Global Village Consulting ranks 44th in 25th annual PROFIT 500 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
>
>
>
>
>
>
>
>
>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden