I am pleased to announce release 1.0.0 of ASUnit, a (the?) pure AppleScript unit testing framework. This release adds compatibility with Mavericks and a lot of other improvements and bug fixes. I have used it for a while and I think that it is pretty stable. You can run tests in AppleScript Editor or from the command-line and you can easily run all the test files inside a folder at once.
The code is too long to be posted here, but you can clone it, together with examples, templates and documentation, from Github:
only after I have posted mine (thanks McUsrII for the interesting posts!). Inspired by it, I have made further improvements to ASUnit (in particular, I have added assertions to test for approximate equality, and colored output in the terminal!). Version 1.2.0 is available here: https://github.com/lifepillar/ASUnit/releases
Below you find the planet test suite from the above thread re-written using ASUnit, which should give you a flavor of the syntax used (for simplicity, I have included only the tests for Mercury and Venus). The output in AS Editor looks as follows (but with colors!):
property parent : script "ASUnit"
property TopLevel : me
property suitename : "Planets (by McUsrII)"
property suite : makeTestSuite(suitename)
autorun(suite)
(* Here go the scripts to be tested *)
-- Tests
script |Julian test|
property parent : TestSet(me)
script |Test of Julian Dates|
property parent : UnitTest(me)
assertEqual(-3543.0, TopLevel's JD(1990, 4, 19) as real)
end script
end script
script |Test Mercury|
property parent : TestSet(me)
property mercury : missing value
on setUp()
set mercury to TopLevel's makePlanet()
end setUp
script |Longitude of ascending node of mercury|
property parent : UnitTest(me)
mercury's setLongAscNode(48.3313, 3.24587E-5, mjd)
assertEqualAbsError(mercury's getLongAscNode(), 48.2163, 1.0E-5)
end script
script |Inclination of mercury|
property parent : UnitTest(me)
mercury's setInclination(7.0047, 5.0E-8, mjd)
assertEqualAbsError(mercury's getInclination(), 7.0045, 1.0E-4)
end script
script |Mercury's argument of Perihelion|
property parent : UnitTest(me)
mercury's setArgOfPerihelion(29.1241, 1.01444E-5, mjd)
assertEqualAbsError(mercury's getArgOfPerihelion(), 29.0882, 1.0E-4)
end script
script |Mercury's semi major axis|
property parent : UnitTest(me)
mercury's setSemiMajorAxis(0.387098)
assertEqualAbsError(mercury's getSemiMajorAxis(), 0.387098, 1.0E-4)
end script
script |Mercury's eccentricity|
property parent : UnitTest(me)
mercury's setEccentricity(0.205635, 5.59E-10, mjd)
assertEqualAbsError(mercury's getEccentricity(), 0.205633, 1.0E-4)
end script
script |Mercury's mean Anamoly|
property parent : UnitTest(me)
mercury's setMeanAnamoly(168.6562, 4.0923344368, mjd)
assertEqualAbsError(mercury's getMeanAnamoly(), 69.5153, 1.0E-4)
end script
end script -- Test Mercury
script |Test Venus|
property parent : TestSet(me)
property venus : missing value
on setUp()
set venus to TopLevel's makePlanet()
end setUp
script |Longitude of ascending node of venus|
property parent : UnitTest(me)
venus's setLongAscNode(76.6799, 2.4659E-5, mjd)
assertEqualAbsError(venus's getLongAscNode(), 76.5925, 1.0E-4)
end script
script |Inclination of Venus|
property parent : UnitTest(me)
venus's setInclination(3.3946, 2.75E-8, mjd)
assertEqualAbsError(venus's getInclination(), 3.3945, 1.0E-5)
end script
script |Venus's argument of Perihelion|
property parent : UnitTest(me)
venus's setArgOfPerihelion(54.891, 1.38374E-5, mjd)
assertEqualAbsError(venus's getArgOfPerihelion(), 54.842, 1.0E-4)
end script
script |Venus's semi major axis |
property parent : UnitTest(me)
venus's setSemiMajorAxis(0.72333)
assertEqualAbsError(venus's getSemiMajorAxis(), 0.72333, 1.0E-5)
end script
script |Venus's eccentricity|
property parent : UnitTest(me)
venus's setEccentricity(0.006773, -1.302E-9, mjd)
assertEqualAbsError(venus's getEccentricity(), 0.006778, 1.0E-4)
end script
script |Venus's mean Anamoly|
property parent : UnitTest(me)
venus's setMeanAnamoly(48.0052, 1.6021302244, mjd)
assertEqualAbsError(venus's getMeanAnamoly(), 131.6578, 1.0E-4)
end script
end script -- Test Venus