@@ -677,12 +677,12 @@ class UnitTestClass
677677 -- @tparam [opt=nil (unordered)] {string, ...} An list of test names in the desired execution order.
678678 -- Only tests mentioned in this table will be performed when running the whole test class.
679679 -- If unspecified, all tests will be run in random order.
680- new : ( @name , args = {} , @testSuite ) =>
680+ new : ( @name , args = {} , @order , @ testSuite) =>
681681 @logger = @testSuite . logger
682682 @setup = UnitTestSetup " setup" , args. _setup, @
683683 @teardown = UnitTestTeardown " teardown" , args. _teardown, @
684684 @description = args. _description
685- @order = args. _order
685+ @order or = args. _order
686686 @tests = [ UnitTest ( name, f, @) for name, f in pairs args when " _" != name\ sub 1 , 1 ]
687687
688688 -- - Runs all tests in the unit test class in the specified order.
@@ -692,7 +692,7 @@ class UnitTestClass
692692 -- @treturn[2] boolean false (test class failed)
693693 -- @treturn[2] {@{UnitTest}, ...} a list of unit test that failed
694694 run : ( abortOnFail, order = @order ) =>
695- tests = @tests
695+ tests, failed = @tests , {}
696696 if order
697697 tests, mappings = {} , { test. name, test for test in * @tests }
698698 for i, name in ipairs order
@@ -763,19 +763,19 @@ class UnitTestSuite
763763 -- @tparam [opt=nil (unordered)] {string, ...} An list of test class names in the desired execution order.
764764 -- Only test classes mentioned in this table will be performed when running the whole test suite.
765765 -- If unspecified, all test classes will be run in random order.
766- new : ( @namespace , args ) =>
766+ new : ( @namespace , classes , @order ) =>
767767 @logger = Logger defaultLevel : 3 , fileBaseName : @namespace , fileSubName : " UnitTests" , toFile : true
768768 @classes = {}
769- switch type args
770- when " table" then @addClasses args
771- when " function" then @importFunc = args
772- else @logger \ error msgs. new. badClassesType, type args
769+ switch type classes
770+ when " table" then @addClasses classes
771+ when " function" then @importFunc = classes
772+ else @logger \ error msgs. new. badClassesType, type classes
773773
774774 -- - Constructs test classes and adds them to the suite.
775775 -- Use this if you need to add additional test classes to an existing @{UnitTestSuite} object.
776776 -- @tparam {[string] = table, ...} args a hashtable of @{UnitTestClass} constructor tables by name.
777777 addClasses : ( classes) =>
778- @classes [ # @classes + 1 ] = UnitTestClass ( name, args, @) for name, args in pairs classes when " _" != name\ sub 1 , 1
778+ @classes [ # @classes + 1 ] = UnitTestClass ( name, args, args . _order , @) for name, args in pairs classes when " _" != name\ sub 1 , 1
779779 if classes. _order
780780 @order or= {}
781781 @order [ # @order + 1 ] = clsName for clsName in * classes. _order
0 commit comments