AS3 :: Flex : Use Hamcrest To Test For Membership In An IList?
Jun 1, 2010
I'm using Flex 3.3, with hamcrest-as3 used to test for item membership in a list as part of my unit tests:
var myList: IList = new ArrayCollection(['a', 'b', 'c']).list;
assertThat(myList, hasItems('a', 'b', 'c'));
The problem is that apparently the IList class doesn't support for each iteration; for example, with the above list, this will not trace anything:
for each (var i: * in myList) { trace (i); }
However, tracing either an Array or an ArrayCollection containing the same data will work just fine.What I want to do is (without having to tear apart my existing IList-based interface) be able to treat an IList like an Array or an ArrayCollection for the purposes of testing, because that's what hamcrest does:
override public function matches(collection:Object):Boolean
{
for each (var item:Object in collection)
{
I'm trying to test a custom Flex 4 skinnable component, using the FlexUnit UIImpersonator class. If I run my tests from a FlashBuilder Spark only project everything works fine. If I try to test from a project with the mx component set on the classpath I get a "getElementIndex not available in non Flex 4 projects" error.Can I unit test spark components in FlexUnits visual test environment while still having the mx component set on the classpath?
UIImpersonator delegates it's method calls to a "testEnvironment".The implementation used for this "testEnvironment" is decided by the VisualTest EnvironmentBuilder class and the FlexEnvironmentBuilder class. If the FlexEnvironmentBuilder class can find the "mx.core.Container" on the classpath it returns a MX environment, else a Spark environment. Only the spark environment has valid implementations for Flex 4 relevant method calls on the UIImpersonator - like the addElement method.
In FlexUnit 1 it is possible to access the name of the currently-running test using the TestCase.getName() method because all tests subclass TestCase. In FlexUnit 4, however, there's no base class for tests; the tests are identified by annotations. So, how can I replicate the getName() functionality in FlexUnit 4?
I'am working with Adobe AIR application and i have a registration form which contains a combobox which consist of 2 values...i want to store the selected value to a variable..
My buttons only work when I click on them on the stage while having the "enable simple buttons" option on. They do not work if I try to "test movie," "test scene" and publish it to a SWF. Nothing responds whenever I am in these modes. I am using Adobe Flash Professional CS5 Actionscript 2.0.
i have a movie that has worked fine in past during Html test but ive been doing some dubugging using the flash test latly and it runs fine here but when i go back and try to test in Html mode no errors come just the movie never fully starts (starts up about as much as if there was an error).
I have two scenes in my flash file and in scene 1, first button takes you to frame 2 where movie clip is -works
on (release) { gotoAndStop("scene1",2); } second button takes you to frame 3
but on scene 2 that performs same function as scene 1, the first button
on(press){ gotoAndStop("scene2",2); }
instead of going to frame 2 goes to frame 3. and the second button goes correctly to frame 3.that happens when i test scene! when i test movie all buttons work properly.
I'm testing some event dispatch code in a Flex app, using FlexUnit's addAsync method for testing that events are dispatched. Great so far, I can ensure that at least one event was fired. However, I want to be a bit more detailed; I want to ensure that exactly the set of events I'm expecting are dispatched. Is there a useful test pattern (or, even, different test framework -- I'm flexible!) to accomplish this?I tried this code, but it doesn't seem to get invoked the second time:[code]
I have a component that, on creation, dispatches two events to populate data fields. The events should remain separate because they're used elsewhere for distinct actions.
I want to write an asynchronous flexunit test to confirm that these events are both sent. The problem is, they're both variants of the same event.
Here's the code:
[Code]....
The thing is, this only tests that the first get data event is dispatched, and worse, depends on the order of event dispatch. How can I test that both of these events are eventually sent out by this method, regardless of their order?
What is the best method to test the existence of an attribute on an XML object in ActionScript 3 ttp://martijnvanbeek.net/weblog/40/testing_the_existance_of_an_attribute_in_xml_with_as3.html is suggesting to test using
if ( node.@test != node.@nonexistingattribute )
and I saw comments suggesting to use:
if ( node.hasOwnProperty('@test')) { // attribute qtest exists }
But in both case, tests are case sensitiveFrom the XML Specs : "XML processors should match character encoding names in a case-insensitive way" so I presume attribute name should also be match using a case-insensitive comparison.
I have a system where clients connect via http streaming channels and use Producer and Consumer classes to dispatch and receive messages. I need to test the latency of messages in a way that adequately simulates real-world usage when the server is under load. I have 3 ideas for how this may be accomplished. Has anyone tried and succeeded or failed with these methods?
I've developed a Vkontakte application by using Adobe Flex technology with WCF as my server side. The whole thing works perfectly on localhost, but after uploading it to Vkontakte - the WS doesn't seem to work and I get this error[code]...
In ACE Flex 3 , there is a topic "Handle Framework Events". Any document which lists all the 'required' framework events for ACE test? So I could know what are "framework" events and will focus on them.
I needed some guidance on how to use FlexUnit 4 within Flash Builder,to unit test a Parsley-frameworked Flex application.I have tried lookign at one or two sites but with no avail.
I've got a suite of unit tests for my project (pure AS3), and they all work brilliantly outputting standard JUnit XML to the trace output window. However, when I tried to get my test suite running on our continuous integration server I ran up against a wall.Flash is a sandboxed beast, isolated from the file system. I can't see an intuitive way to get this generated JUnit XML in to our CI software so it can be verified as passing.
I've taken a shot at implementing the approach shown in Continuous Integration with Flex,but it relies on reading trace output logged to flashlog.txt that is prone to failure on many fronts (debug player must be installed, flashlog.txt must be created, mm.cfg file must be configured properly). Also, I find that some of the time it fails to find the results in the flashlog and the build fails despite all the tests passing. This could be because I have too many tests and some are being pushed out of the log file.
I've just been tasked with finding automated actionscript frameworks. Can anyone offer the best out there? I'm just beginning to write the code for my project. Is it better for me to keep my MXML and AS in separate files so I can more easily integrate with any frameworks....or does it even matter?
If I have two sibling canvases displayed next to each other, can I have a child Label (or any child component for that matter) in the left canvas overflow outside of that canvas and on top of the next?
My label text is not showing up after binding the arraycollection to the label text. Could I see an example of how to properly bind an arraycollection to a labels text?
If I was using java what I would do is I would create a new package: [url].....
And I would put this code in it:
public class xmlStuffTester { public static void main(String [] args){ XmlStuff xs = new XmlStuff();[code]...
(Alternatly I would write a unit test if I knew exactly what the xml output should be. I don't know that yet so I prefer the above approach.)Question: What is the standard way to do this in Flex builder?
As the title indicates the question is in regards to the service layer of a flex application. Specifically in a test case class. To call the services the user must first authenticate through an html/CF based page. Once that's done and the authentication has occurred the user is directed to the html page with the flex application embedded in. Once authenticated the server side CF code writes a cookie to the users computer. This cookie is then read by the flex app and is required for the flex app to make calls to the CF services.
The question is: how should this be handled in a test case class for the service class in the flex app? The following steps need to basically take place: use some account data to hit the server and authenticate, the cookie then needs to be written (which it will already), then the test case needs to pick up the session id from the cookie and pass it to the service call within the test case. That just all seems like too much for a test case class.
So, how is this type of thing usually handled. From what I gather it's typical for web service calls to require a session id like this.
I'm trying to unit test memory management. So far I have a semi-workable solution using flash.sampler.getSamples to get the difference between the number of NewObjectSamples and DeleteObjectSamples which have the same id value.
The test looks something like this:
startSampling(); new Foo(); new Foo();
[Code].....
Since there are no references to Foo I'm assuming that all instances are being garbage collected, and my code is simply wrong due to my lack of understanding how sampling works. I am trying this instead of using weakly keyed dictionary because it seems it should be less of a hack, but now I'm starting to wonder if it's worth the trouble.
I am interested in doing automated testing against a Flex based UI.I have found out that my best options for UI automation (due to being C# controllable, good licensing conditions, etc)all seem to require that I compile test hooks into my application.Because of this, I am thinking of recommending that these hooks be compiled into our build.
Warning! Automation enabled applications expose all properties of all GUI components. This makes them vulnerable to malicious use.Never make automation enabled application publicly available. Always restrict access to such applications and to RIATest Loader to trusted users only.