Hey everyone,

You may have noticed that I committed a new RoyaleUnit library to royale-asjs 
yesterday. It is a unit testing library, similar to (and greatly inspired by) 
FlexUnit. It is an upgrade to the barebones "Testing" library that was based on 
my work from a while back. I brought a number of things more in line with 
FlexUnit's API.

* RoyaleUnit runs in web browsers, Node.js, and in the Flash runtimes.
* For basic tests, in addition to the existing [Test], [Before], and [After] 
metadata that we already had, I also added [Ignore], [BeforeClass], and 
[AfterClass].
* I also added [Suite] and [RunWith] metadata to run suites of tests.
* I added a CIListener, similar to FlexUnit's, that supports connecting to the 
socket server that FlexUnit's Ant task creates. Currently, CIListener only 
works in the Flash runtimes. In other environments, you can use TraceListener() 
and the results will be printed to the console with trace(). There's also a 
FailureListener that may be useful. For instance, in Node.js or AIR, you might 
use it to quit with different exit codes.

As part of this process, I also updated the existing tests that we run when 
building the Core and Basic libraries. It basically involved updating the 
[RunWith] metadata with a new class, and switching the app startup to use 
RoyaleUnitCore instead of FlexUnitCore. As I mentioned above, we can still use 
FlexUnit's Ant task for SWFs, and I confirmed that this is working correctly in 
the Ant build scripts.

I can probably get the CIListener working in Node.js too, since it natively 
supports sockets. However, web browsers don't support raw TCP sockets in JS. 
Browsers have WebSockets, which are similar, but not exactly the same. 
WebSockets require a special handshake to initialize the connection that 
requires the server to support it. With that in mind, FlexUnit's Ant task does 
not support WebSockets. However, it may be possible to fork/update it to add 
that handshake.

I'm sorry if I broke anything for anyone that was using the existing Testing 
library. However, it's pretty easy to upgrade to RoyaleUnit. If you need some 
example code, take a look at the tests for the Core library:

https://github.com/apache/royale-asjs/tree/develop/frameworks/projects/Core/src/test/royale

If you need any help upgrading to RoyaleUnit, please let me know, and I'll be 
happy to help!

- Josh

Reply via email to