You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by piotrz <pi...@gmail.com> on 2015/02/22 12:40:16 UTC

[FLEXUNIT, TLF] Problem with applying appropriate data for tests

Hi Guys,

I have started to working on our TLF unit tests - loading configuration data
from existing xml for every test method (path in repository:
test\testCases\).
Almost every test unit class in TLF has his own xml file with tests method
configuration. For example:

ContainerAttributeTest.as has:

https://paste.apache.org/8O4X

As you can see test method "checkColumnWidthOnGapChangeTest" will launch
with different set of parameters. Currently most of the tests are lanuching
with default values.

In my ContainerAttributeTest I'm loading xml [1] using two lines of code:

https://paste.apache.org/d4gR

Once data has been loaded in my "dp" Array I will have for example 100
"TestCase".

PROBLEM:
[Test(dataProvider=dp)]
public function checkColumnWidthOnGapChangeTest(dpData:Object):void
{
}
If I add my data provider to the test above it will launch 100 times, but
only two cases from this xml file is for this test.

Does anyone have an idea how can I say to my test method - "Hey launch only
couple of times and pickup only data suits to you from the data provider" ?
:)

[1] http://bit.ly/1EEEzHp

Piotr







-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FLEXUNIT-TLF-Problem-with-applying-appropriate-data-for-tests-tp45201.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

RE: [FLEXUNIT, TLF] Problem with applying appropriate data for tests

Posted by piotrz <pi...@gmail.com>.
Michael,

I've just committed my changes and applied it to one test class. You can
take a look into that.

I'm filtering data inside loader based on the tests name:

https://git1-us-west.apache.org/repos/asf?p=flex-tlf.git;a=commit;h=6155a8ab

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FLEXUNIT-TLF-Problem-with-applying-appropriate-data-for-tests-tp45201p45390.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

RE: [FLEXUNIT, TLF] Problem with applying appropriate data for tests

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
>"checkfirstBaselineOffset" and "checkColumnWidthOnGapChangeTest"

>I will create -> https://paste.apache.org/7Qka

This is pretty close to what I was suggesting in my original comment.

Mike


RE: [FLEXUNIT, TLF] Problem with applying appropriate data for tests

Posted by piotrz <pi...@gmail.com>.
One solution which came up to my mind is create for every test's methods data
loader.

So for example if we have two test methods which has some configuration:

"checkfirstBaselineOffset" and "checkColumnWidthOnGapChangeTest"

I will create -> https://paste.apache.org/7Qka

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FLEXUNIT-TLF-Problem-with-applying-appropriate-data-for-tests-tp45201p45343.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

RE: [FLEXUNIT, TLF] Problem with applying appropriate data for tests

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
I would look at your code again. I don't think it's doing what you think it's doing. A few things including that slice returns a shallow copy. You make a copy and pass the original up.

However, you don't need a rule at all. Just do this work in the loader.

Load your data but ensure you only pass what's needed up. If you want to send me your TestConfigurationLoader, I can fix it.

Mike


RE: [FLEXUNIT, TLF] Problem with applying appropriate data for tests

Posted by piotrz <pi...@gmail.com>.
Hi Michael,

I did my own custom data loader and it's working fine. I will describe you
everything on a simpler example. Maybe I don't understand something.

1) I've created my Test class 

https://paste.apache.org/juCo

My "TestConfigurationLoader" class loading data from xml into my data
provider "dp". Inside my loader I'm parsing xml and create custom Vo
objects. My array will have 188 objects after parsing.

2) I'm creating a custom "Rule" - As you probably know "Rule" is launching
before any test method class is launch. 

https://paste.apache.org/8TUw

I'm removing items from array - Leave only one.

3) First test is launching "testTest". I see in the debugger that in my data
provider "dp" I have 1 item, but my test is launching 188 times. Why ? -
This is the point which I don't understand. Any idea ?

Piotr





-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FLEXUNIT-TLF-Problem-with-applying-appropriate-data-for-tests-tp45201p45312.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

RE: [FLEXUNIT, TLF] Problem with applying appropriate data for tests

Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
PROBLEM:
[Test(dataProvider=dp)]
public function checkColumnWidthOnGapChangeTest(dpData:Object):void
{
}
>If I add my data provider to the test above it will launch 100 times, but only two cases from this xml file is for this test.

This is just not how you are supposed to use this feature. It's supposed to run every line of the dataProvider like its doing.

1) Follow the approach of doing your own dependency loader (later in the link you reference) and filter the results down to what you want. You could make the constructor take an argument indicating the filter or something similar. That's the only method that is going to work reliably.

Something like:

public static var dataRetriever1:ParamDataHelper = new MySuperSpecialParamDataHelperWithFilter( "PurelyFakeExample.xml" , 'a=1'); 
//Please note this class (MySuperSpecialParamDataHelperWithFilter) doesn't exist, you would need to write it per the docs you reference


2) This _might_ work, I am honestly not sure, you could try to make your public variable a getter/setter instead and, in the setter, filter the data.... again, not sure that will work. I don't remember if I take setters into account in the code.

Mike