How to run Flex unit tests from the command line on Linux? - apache-flex

I am setting up a FlexBuilder build under Hudson/Jenkins on a Linux system. I want to execute our unit tests, but do it without using the standard GUI-based test runner.
What are my options?

Folks seem to use something called xvfb. I haven't tried this solution myself so I'll just give you the links to the revelant articles I know :
http://www.benlondon.co.uk/2010/02/running-flexunit-09-tests-on-headless.html
http://life.neophi.com/danielr/2007/12/headless_linux_automated_flexu.html
http://www.brianlegros.com/blog/2009/12/20/using-xvnc-to-create-headless-ci-builds-for-flex-and-air-applications/
http://www.brianlegros.com/blog/2010/01/19/flexunit-and-continuous-integration-updates/

Related

Configure Eclipse to run my FlexUnit tests automatically

I'd like to set up my projects in Eclipse to run FlexUnit tests everytime I save my work.
I found an example with JUnit here : http://misko.hevery.com/2009/05/07/configure-your-ide-to-run-your-tests-automatically/
How would you do it? Is it possible to run FlexUnit tests without Flash Player?
Yes, you could create a setup much like the one Misko describes using FlexUnit4. The key is creating an ANT build script that compiles your test runner and then invokes the FlexUnit ANT task on the resulting SWF.
Once you have the ANT build script setup you can jump right into step 4, as outlined in the article.
Getting the ANT build script setup correctly can be a little tricky if you're not familiar with ANT. I found the continuous integration (CI) sample project provided by the FlexUnit4 team to be a great reference. As of this writing, it's available here:
http://opensource.adobe.com/svn/opensource/flexunit/branches/4.x/FlexUnit4SampleCIProject/
Try using Flex Builder 4 beta, it has unit testing integration built in.
Are you using the FlexUnit plugin for Eclipse?
I don't know it, but it should execute FlexUnit tests.
If you want to execute something after you saved, you could use the Save Actions in Eclipse. They are inserted in org.eclipse.jdt.ui.cleanUps (according to a mailing list post).
Oh, I recently found this blog entry: FlexUnit + Ant. It seems like it covers your problem!
Good luck with that!

Flex, Ant and TeamCity

Is anyone using TeamCity for building their Flex apps? We're using .Net for our main site code and backend flex data calls and we use flex for our application. I have a working Ant build script, but I can't get it to run with the TeamCity Ant Runner. I'm curious if anyone has gotten this working and if they have, could I potentitially see a sample of your build script?
For some reason the build script won't pick up the FLEX_HOME environment variables for the Flex Ant Tasks.
I cannot see why it shouldn´t work. Just declare FLEX_HOME in the top of your Ant script, and point to the sdk on the TeamCity machine, like:
<property name="FLEX_HOME" value="c:/adobe/flex/sdk/3.3"/>
On a previous project I worked on we had exactly the same situation as you and it can work. I can't remember doing anything special to get this going although we may have had to manually set some environment variables in the TeamCity config. Check out the TeamCity docs for how to set these and how to they are used
You might also try using the basic Command line runner to see if that works. When troubleshooting environment variable issues in TeamCity I have found it useful to have part of the build process run a DOS set command (env for Linux) and then look in the build logs to see what the actual environment is.

Best build system for embedded development/cross-compiling

I'm doing some development right now using dsPICs and I'm not exactly in love with MPLAB. I'm actually using Visual Studio with a makefile project. Currently I'm using SCons, which seems to work fairly well, after finding a helpful guide to setting up to use an alternate compiler. Still, I can't help but wonder, is there a better build system for this? And also, is there a better way to make Scons do this?
Just use vim, makefiles and call the MPLAB command line compiler yourself.
There are quite a few build systems that you can use:
Buildroot http://www.buildroot.net/
Buildroot-ng http://wiki.openwrt.org/
crosstool-NG http://www.crosstool-ng.org/
PTXdist http://www.ptxdist.org/
OpenEmbedded http://www.openembedded.org/
OE-lite http://oe-lite.org/
muddle https://code.google.com/p/muddle/
Poky http://pokylinux.org/
OpenBricks http://www.openbricks.org/
Yocto Project http://www.yoctoproject.org/
Scratchbox http://www.scratchbox.org/
Cross Linux From Scratch http://www.cross-lfs.org/
Aboriginal Linux http://landley.net/aboriginal/
The very simplest way to do embedded development is to use your favourite code editor for writing the code, then switch to the compiler's IDE to build and download the code to the processor.
Obviously, the code editor and the compiler IDE may be the same thing, which is even simpler!

Compile Flex Builder project from command line

Is there an easy way to build projects created in FlexBuilder via the command line?
I'm beginning to work on adding a couple Flex components to the project I have at work. Currently the rest of the project (some java, some C++) is built via an ant script. I'd really like to be able to integrate the builds for the Flex components I'm working on into that ant script, but I'm not sure how to build the Flex projects from the command line.
Is there a way to invoke the flex compiler from the command line such that it uses the flex builder's project as its configuration? Or is there a way to modify FlexBuilder's compilation so that I could write a build script for the project and then have it use that (so that I'd only have one way to build and have both ant and FB use that, instead of separate build processes)?
While a flex ant task would be preferable it's not really necessary, as I can create custom tasks from command line apps easily enough.
EDIT:
One additional thing that I should probably mention. While I have FlexBuilder installed some of the people who run that ant script do not. They would just have the normal Flex SDK.
You can use the -dump-config option in FB to dump the config.xml that FB is using to compile your project, and then use that (using the -load-config option) with your command-line build.
I know in regular Eclipse you can build from an ant file, and I'm pretty sure that you can do the same with FB.
Although the doc kind of stinks for the flex ant tasks, they work ok.
[EDIT]- I replied in the comments, but I wanted to flesh out my reply.
Herms is having a problem using -dump-config and -load-config and it kind of points out why the flex ant tasks are better. (I didn't want to be the guy who says "why do you want to do X?", so I just answered the asked question).
Even though their doc is subpar (imo), they're better suited for the task of building
your projects.
There are a couple of gotchas using the flex ant tasks, but for the most part, it's not brain surgery (and really the gotchas are more because the doc sucks).
When I started working on the automated build for our project, I found this site:
http://www.nabble.com/FlexCoders-f16212.html
to be invaluable.
Flex 3 comes with Ant tasks for building Flex applications from the command line. The documentation is available here. In addition, there is a great open source build framework called Antennae which can help a lot in organizing and building Flex applications from the command line (it is Ant-based).
I wrote a blog post on exactly how to do this (set Flex up with Ant) and have a sample build file. while I wrote this for Linux, the Ant part is platform agnostic. (see step 4):
http://blog.apterainc.com/software/setting-up-a-flex-development-enviroment-in-gnulinux/
If you need any help, leave comments and I can troubleshoot any problems you are having.
EDIT: Documentation for Flex's ant tasks are a bit sparse, but here are the official documentation from Adobe, is was enough to get me on my way: http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html
I started out with Antennae and was pretty disappointed when I realized it does not use the Flex Ant Tasks. To get what I needed I would've needed to hack the command line parameters it passes to mxmlc... and antennae doesn't support modules among other things that are easier to accomplish with the Flex Ant Tasks. anyway, what I did come up with is a mash up of the good aspects I found in antennae and the good aspects of the build files from this blog post:
http://jvalentino.blogspot.com/2010/03/flex-ant-build-optimized-modules_24.html

Can you do "builds" with PHP scripts or an interpreted language?

Correct me if I'm wrong, but a "build" is a "compile", and not every language compiles. Continuous Integration involves building components to see if they continue to work beyond unit tests, which I might be oversimplifying. But if your project involves a language that does not compile, how do you perform nightly builds or use continuous integration techniques?
Hmm... I'd define "building" as something like "preparing, packaging and deploying all artifacts of a software system". The compilation to machine code is only one of many steps in the build. Others might be checking out the latest version of the code from scm-system, getting external dependencies, setting configuration values depending on the target the software gets deployed to and running some kind of test suite to ensure you've got a "working/running build" before you actually deploy.
"Building" software can/must be done for any software, independent of your programming langugage. Intepreted languages have the "disadvantage" that syntactic or structural (meaning e.g. calling a method with wrong parameters etc.) errors normally will only be detected at runtime (if you don't have a separate step in your build which checks for such errors e.g. with PHPLint).
Thus (automated) Testcases (like Unit-Tests - see PHPUnit or SimpleTest - and Frontend-Tests - see Selenium) are all the more important for big PHP projects to ensure the good health of the code.
There's a great Build-Tool (like Ant for Java or Rake for Ruby) for PHP too: Phing
CI-Systems like Xinc or Hudson are simply used to automagically (like anytime a change is checked into scm) package your code, check it for obvious errors, run your tests (in short: run your build) and report the results back to your development team.
Create a daily tag of your current source control trunk?

Resources