How to use asunit 4?

161 views
Skip to first unread message

mosesoak

unread,
Dec 15, 2010, 3:36:46 PM12/15/10
to ProjectSprouts
Hi Luke, I noticed on github that you have an asunit4 now, but sprout
seems to use asunit3. I'm not sure if there's a separate asunit
mailing list so just asking this here.

Would you mind giving a brief description of what's changed in version
4, whether it's worth updating (I'm using this with the flex4sdk
sprouts gem), and if so how I could upgrade an existing project to use
it?

If you've already posted this information somewhere feel free to
reroute me.

Thanks!
Moses

Luke Bayes

unread,
Dec 15, 2010, 9:40:51 PM12/15/10
to project...@googlegroups.com
Hey Moses,

Thanks for checking in on this!

AsUnit 4 is a full rewrite that Robert Penner started in early 2010.
It is an amazing bit of code that started with the ideas that AsUnit 3
was too slow (and messy) and annotations were too powerful to ignore.

We got it into a usable state this past summer but haven't managed to
put together an announcement or instructional materials.

Robert Penner, Ali and I use it everyday along with a small cohort of
other folks and it has been stable and blazing fast. Unfortunately,
the only documentation for it are it's own tests. The good news is -
that the tests are thorough and provide a pretty great bit of
documentation.

The prerelease build of Sprouts v1 uses AsUnit 4 and provides some
generators and support that make it painless.

Some of the highlights (as I recall) of AsUnit 4 are:

* It's wicked fast
* Composition is better than inheritance
* It uses annotations, which provide enormous flexibility
* It works with Air, Flex, Authoring, and any other ActionScript
3-based environment
* It can swap runners at runtime, so we can support legacy test cases
(or even - at some point - other framework's test cases)
* It's much easier to build custom printers for
* The async functionality is much cleaner

Following are some examples if you're interested:

Runner / Entry Point(s):
AS3:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/test/AsUnitRunner.as

Flex 3:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/test/Flex3Runner.mxml

Flex 4:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/test/Flex4Runner.mxml

AIR 2:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/air/AIR2Runner.mxml


Test Suite:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/test/AllTests.as

Visual Test Case:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/test/asunit/framework/VisualTestCaseTest.as

Async Test Case:
https://github.com/patternpark/asunit/blob/master/asunit-4.0/test/asunit/framework/AsyncMethodTest.as

We did quite a bit of work to introduce a "LegacyRunner" so that one
could use the new framework against a legacy project by simply
swapping out the existing main file - what used to be called a
'Runner', and test suite(s). I'm pretty sure that still works but
haven't confirmed in quite some time. This should make migration of
legacy projects simple and let you move one class at a time.

As far as generators go, it's basically the prerelease of Sprouts v1.

You can grab that with:

gem install sprout --pre

But you should only do this if you're on Ruby 1.9.2 and you can easily
switch Ruby/Gem versions (like with rvm or ruby_switcher).

Hope that helps!

Luke

Moses Gunesch

unread,
Dec 16, 2010, 3:56:51 PM12/16/10
to project...@googlegroups.com
Fantastic! Thanks for the scoop. It sounds like a nice update.

So can I use asunit4 with the release version of Sprouts or do I absolutely need to use the prerelease? (I mostly use script/generate class and rake test in the current version.)

Anyway I'm happy to either A) grap asunit4 and drop it into my existing sprouts project, but would need to know how to make that work or B) use 1.9.2 + sprouts prerelease to either re-initialize an existing project or start a fresh one, but would need to know the new syntax to do that.

Thanks!


--
You received this message because you are subscribed to the Google Groups "ProjectSprouts" group.
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to projectsprout...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/projectsprouts?hl=en

For other info you can visit our project at: http://projectsprouts.org, or on Github at: http://github.com/lukebayes/project-sprouts

Luke Bayes

unread,
Dec 16, 2010, 5:47:46 PM12/16/10
to project...@googlegroups.com
Hey Moses,

If you're using the release version of Sprouts with the default task
helpers in your Rakefile and using the generators, I'd recommend
sticking with AsUnit 3 (for now).

If you really want to upgrade, you'll need to download the swc
(https://github.com/patternpark/asunit/zipball/4.0.3) and create a new
test task (delete the old one) that includes the library as if it's an
arbitrary swc file. You'll also need to avoid using the built-in
generators... :-(

In case you're still not persuaded...

Here's an example of an AS3 project Rakefile that doesn't use the task
'helpers':

https://gist.github.com/221569

You'll want to avoid the 'library :asunit3' line and just go ahead
with dropping the SWC into your lib dir and adding it to the
library_path of your test swf task.


Thanks,

Luke

Reply all
Reply to author
Forward
0 new messages