I have a flex application written using PureMVC framework.Now,I want to write tests.We are using FlashBuilder 4.Is FlexUnit sufficient for testing? Are there any issues you have faced while writing tests?
I, personally, have had problems getting the Unit testing features of Flash Builder 4 to work. I ended up creating a separate AIR Project and creating Unit Tests in that using FlexUnit 1 (I believe the swc is 0.98 or something similar). I chose that version of FlexUnit because --at the time--documentation was very sparse on FlexUnit 4 and Flash Builder integration. I suspect things have changed on the documentation, and stability front, I have not gone back to that since Flash Builder was released.
Now, I'm not sure specifically how PureMVC works, so can't comment on specifics of unit testing with PureMVC. But, I have found that unit testing works great for model classes; which are often not framework specific. You should have no problem unit testing said classes.
I have found that unit testing is not beneficial for User Interface classes. For something like that an automation testing tool such RIATest or FlexMonkey are better suited.
Does that answer the question?
Related
I want to start using the Google C++ Testing Framework, but I don't understand how it use with Qt?
What should I do to start? How to link GTF to my project and use it? If possible, I'd like a detailed guide.
There is nothing special about testing Qt in particular, just familiarize yourself with google testing and Qt, then write your test cases. You'd test Qt code like you'd test anything else.
Good places to start:
A quick introduction to the Google C++ Testing Framework courtesy of IBM
Getting Started with Qt
The one thing to keep in mind is that a significant part of Qt is event driven, which requires a running event loop.
Additional resources:
Running Autotests in Creator - setting up google test
the Qt Creator Google Test plugin
Edit:
To elaborate on Gluttton's comment, as evidently, other users share the sentiment:
The clarification about the design particularities of Qt should imply two things:
1 - in many cases, individual tests will require an above trivial setup, that is still standard Qt and C++, set up event loops and connections and whatnot - nothing special whatsoever.
2 - in some cases, there is only so much that unit testing can do. Some functionality requires larger and more complicated runtime setups, that are impractical or even impossible in the context of unit testing, thus falling outside of the scope of the google testing framework.
I'm a rails developer, and I want to do some capybara+(rspec or cucumber) style of integration testing with cakephp 2.0. I was using PHPUnit (the default test framework for cake 2.0) but I don't know how to integrate it with Selenium and Cake at the same time to get the full stack effect that you have on rails
So, for the experience php devs that have used cake 2.0... how do you guys do a proper integration testing?
I'm not surprised there's been no answer on this - the community of testers within CakePHP seems to be extremely small. I've worked on large projects with huge numbers of functional and unit tests (currently a suite of around 1500 tests), but to do that I needed to extend the CakePHP test suite functionality (you can take a look at my now slightly outdated TDD plugin).
When we started we didn't know a whole lot about integration testing, and setting up a decent unit testing environment was enough of a challenge. We now use Rails :)
Basically, this is not a well-worn path. To get something working will require an extension to the framework - it will also require a new test case class, which extends PHPUnit_Extensions_Selenium2TestCase, and integrates any necessary functionality from CakeTestCase and ControllerTestCase.
I hope you get somewhere! If you do, it would be great if you could share the code with the rest of the community.
I've recently started practising test driven development - thus far I've been working on a library project, so I've organised my FlexUnit tests in a separate FlexBuilder 3 project, linking against my library's swc.
Now I'm working on a web app and wondering how best to organise the tests for this. At the moment I've put them in a src/test package in the project I'm testing, with the test runner application at the same level as the default application. Is this the best way to do it, or should I have a separate test project and link in the source for the application I'm testing? Or something different?
We don't automate tests at the moment, but this is something I would like to get working at some point, so a structure that would support that in the future would be helpful.
I've had a look at http://docs.flexunit.org/index.php?title=Setting_up_a_FlexUnit_4_Project but this (and the other docs here) explains well how to organise your tests, but doesn't advise on where to sit the tests in relation to the project I'm testing.
Thanks for any help,
cheers, Ange
Yup, I think it's a matter of preferences. I like to have another Flex project that launches FlexUnit tests. So whether your project is a Flex project or a Library Project, you keep the same behaviour when launching tests.
Also, our CI build have it's own test launcher, so there was no need to have another one in our project.
My company is building a Flex application that we may need to port to other platforms:
Silverlight (likely)
Mobile (maybe -- iPhone: Objective-C , Android: Java, etc.)
Desktop (maybe -- AIR, .NET, etc.)
TV sets (maybe eventually)
Currently, I’m looking into application frameworks to build upon and I’m torn between pureMVC and Swiz.
I LOVE swiz for its simplicity and how it just gives you a way to hook things up and then apply your own patterns. From a flex-only perspective, this is my 1st choice.
But, PureMVC is platform-independent and has already been ported over to most of the platforms that are mentioned above. How valuable is this portability? Will it really make our lives significantly easier when it comes to porting and developing/maintaining multiple applications? If so, then it seems like PureMVC is the way to go.
Alternatively, since Silverlight has the most definite business case for porting of our application, maybe we could port Swiz to Silverlight? I'm not too familiar with which AS3 language and Flex framework features Swiz depends on and whether they are available in C#/Silvelright. Would this actually be possible?
Thanks so much!
Karthik
The way I see it, if you used pureMVC you could port to a new language, without too much trouble (other than what the new language will give you) your commands, mediators and proxies, provided you program your mediators to an interface, instead of a concrete component implementation, and the proxies use a services layer to get the data from server. That way you'll only have to implement the components and the service layer in the new language.
A quick look at the Swiz framework:
uses the flash event model (see CentralDispatcher)
uses some flash.net, and mx.rpc classes (see net and rpc swiz packages)
PureMVC framework doesn't use the flash event model, and eventual flash.net/mx.rpc references would normally appear in the service layer. On the other hand Swiz seems to be aimed at taking full advantage of flex, and the mxml format, so it might get the job done faster there. So you might also want to consider using Swiz for flex and PureMVC for the other languages.
Any framework, including Swiz, can very easily be ported to just about any language. Actionscript is touring complete, so theoretically any code writen in actionscript can be transformed into another touring complete language. For example, we use the Swiz framework in our mobile apps, which get cross compiled to run in iOS. There are many other open source cross compilers for a variety of languages, as well as Adobe's Alchemy project.
The only thing that is not easily portable in Swiz the usage of runtime metadata tags. This can be solved by using an advanced search and replace utility, or a custom transformation framework to convert custom metadata tags to their native code implementation. Hopefully we will see some cool new open source tools for this soon, now that Flex 4.5 was released with custom compiler hooks.
In short, I wouldn't even take portability into consideration when deciding on a framework. Choose the one which is most comfortable for you or your developers to use. I personally prefer Swiz myself.
Cheers!
I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of FlexUnit but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one exist?
Also, are there any other resources on how to do Flex development "the right way" besides the Cairngorm microarchitecture example?
The dpUint testing framework has a test runner built with AIR which can be integrated with a build script.
There is also my FlexUnit automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:
<target name="run-tests" depends="compile-tests">
<flexunit swf="${build.home}/tests.swf" failonerror="true"/>
</target>
On my project we're using Maven to build both our Flex RIA and the Java-based back end. In order to build and test the Flex app we use the flex-mojos maven plugins. They do a great job for us and I would highly recommend using Maven over Ant.
That being said, if you're already using Ant it can be a little tricky to transition over to Maven. So if you're in that position I would recommend using the flexunit tasks available here: Ant Task
Both of these libraries do basically the same thing, they launch a generated flexunit test runner mxml application in a window and open a socket connection back to the build process using a JUnit test runner. Amazingly enough it works pretty well. The only problem is that you can't run it headless so if you want to run the build from a CI server you have to make sure that process has the ability to launch new windows otherwise it won't work.
About how to develop Flex applications the right way, I wouldn't look too much at the Cairngorm framework. It does claim to show "best practice" and so on, but I would say that the opposite is true. It's based around the use of global variables, and other things you should try to avoid. I've outlined some of the problems on my blog.
I would suggest that you look at the Mate framework instead, which has good documentation and good examples to get you going. It uses Flex to its full potential, doesn't rely on global variables as Cairngorm and PureMVC, and it makes it possible to write much more decoupled code.
An alternative to FlexUnit is the AsUnit testing tools. There are versions for actionscript 2 and 3. It also has good integration with Project Sprouts, which is a build tool for Flex and Flash similar to ant, however it uses ruby rake tasks and includes excellent dependency management along the lines of maven.
No IDE integration that I know of however.