Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dbackeus/leanunit-actionscript2
Sweet and lean unit test framework for actionscript 2.0
https://github.com/dbackeus/leanunit-actionscript2
Last synced: 3 months ago
JSON representation
Sweet and lean unit test framework for actionscript 2.0
- Host: GitHub
- URL: https://github.com/dbackeus/leanunit-actionscript2
- Owner: dbackeus
- Created: 2008-09-11T21:18:00.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2008-09-13T21:17:00.000Z (about 16 years ago)
- Last Synced: 2024-06-23T19:36:43.736Z (5 months ago)
- Language: ActionScript
- Homepage:
- Size: 109 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
- awesome-actionscript-sorted - leanunit-actionscript2 - Sweet and lean unit test framework for actionscript 2.0 (Frameworks / Unit Testing)
README
= LeanUnit
* http://github.com/dbackeus/leanunit-actionscript2
== THE STORY
After wasting too much time trying to figure out ASUnit and feeling sick about how bloated its codebase was I decided to roll my own. This is the result.
Note: I later realized I had been looking only at asunit2 when I should have been looking at the refactored and better looking asunit25. That said asunit25 still looks like Java and Actionscript is not Java. LeanUnit is a whole lot leaner and to the point if you'll pardon my shameless self promotion.
== REQUIREMENTS
A flash compiler. Example files are provided for Flash 8 and MTASC.
== INSTALL
If you don't have git you can get the files by using the download link at the github homepage. Otherwise just clone them from git.
git clone git://github.com/druiden/leanunit-actionscript2.git
Then either copy the leanUnit directory into your actionscript project source directory or link the cloned directory in your fla classpath (publish settings -> flash -> settings).
== USAGE
After installing, the first thing you need to do is create a test case class with the tests you want to run. If you don't feel like starting from scratch just to see how it works you can go ahead and checkout the 'example' directory.
=== Naming Conventions
There are some conventions for how you name your test classes and where you put them.
* They should reside in a 'test' directory relative to your projects source directory.
* They should start with the name of the class you want to test.
* They should end with Test.as.So if you're making a test class for your Person class you would create test/PersonTest.as. You are not forced to follow the conventions but I strongly recommend it to keep things nice and structured.
=== Structure of the Test Class
So now that your newly created test class looks good from the outside. What to make of the inside.
* All test classes must inherit from leanUnit.TestCase
* All test functions must start with 'test'
* You can add a setup function that will be run before every test function
* You can add a teardown functino that will be run after every test functionThe following is an example of a test class for String.
// test/StringTest.as
class test.StringTest extends leanUnit.TestCase
{
var string:String
function setup()
{
string = 'Asdf'
}
function testLength()
{
assertEqual(4, string.length)
}
function testToUpperCase()
{
assertEqual( 'ASDF', string.toUpperCase() )
}
function teardown()
{
delete string
}
}When your test class is created you can run it by adding it to a test suite call run on the suite instance.
=== Using the Flash IDE
Add code for running your test class in the framescript of the .fla, like:
import leanUnit.*
import test.*
new TestSuite( StringTest ).run()Then export the .fla and watch the results.
=== Using the MTASC compiler
Create an .as file to be the entry point for the compiler:
// MtascMain.as
import leanUnit.*
import test.*
class MtascMain
{
static function main(root)
{
var suite = new TestSuite( StringTest )
suite.run()
}
}Then compile from the command line using something like:
mtasc -swf test/example.swf -header 550:400:10:080808 -main MtascMain.as
Now you can run the generated .swf through Flash Player or from your webbrowser and watch the results.
=== Running Multiple Test Cases
You can add any number of test cases you want to run to your test suite before running it. TestSuite extends Array so you can work with it just like an array.
import leanUnit.*
import test.*// The horisontal way
var suite = new TestSuite( StringTest, ArrayTest )
suite.run()
// The vertical way
var suite = new TestSuite()
suite.push( StringTest )
suite.push( ArrayTest )
suite.run()// The oldschool way
var suite = new TestSuite()
suite[0] = StringTest
suite[1] = ArrayTest
suite.run()== LICENSE
(The MIT License)
Copyright (c) 2008 David Backéus
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.