I managed to add a new preReq method and to amend the cleanUp method to be executed at the beginning of a TestCase and at the end, so before and after all the tests run.
I added them because I think, in some test cases, you want to prepare the field for the tests and then clean it up. For example you want to create some mock objects that are going to be used in more that one test and you don’t want to create/destroy them in each setUp/tearDown.
So the new TestCase sequence is
preReq
setUp
testMethod
tearDown
setUp
testMethod
tearDown
….
cleanUp
I also added the ability to handle async operations in all the states of the TestCase preReq/setUp/tearDown/cleanUp. In the previous version the tearDown and cleanUp didn’t handle async operations.
There was also a little gotcha in the original version of AsUnit, it didn’t consider the fact that some event callbacks can be too fast and it wasn’t picking them up correctly. To fix that I added new flags to double check if a state has finished processing async operations and so avoid calling the next state twice.
Your preReq idea is quite useful. FlexUnit 4 has the equivalent concept using the [BeforeClass] metadata tag. I support this tag in AsUnit 4, which I am writing in my FreeRunner branch to support supporting JUnit 4-style tests like FlexUnit 4.
I think the running logic in AsUnit 3 TestCase is a bit messy. For AsUnit 4, I re-wrote the runners from scratch. I moved a bunch of logic into TestIterator and SuiteIterator.
I think that the way I’ve implemented async methods is a lot simpler and cleaner than AsUnit 3. I suggest looking around the asunit4 package in my FreeRunner branch for ideas.
Your preReq idea is quite useful. FlexUnit 4 has the equivalent concept using the [BeforeClass] metadata tag. I support this tag in AsUnit 4, which I am writing in my FreeRunner branch to support supporting JUnit 4-style tests like FlexUnit 4.
I think the running logic in AsUnit 3 TestCase is a bit messy. For AsUnit 4, I re-wrote the runners from scratch. I moved a bunch of logic into TestIterator and SuiteIterator.
I think that the way I’ve implemented async methods is a lot simpler and cleaner than AsUnit 3. I suggest looking around the asunit4 package in my FreeRunner branch for ideas.
yeap I found the preReq and cleanUp really useful in my latest tests.
I really need to have a look at your freerunner the only thing I’m worried about is changing all my tests to conform
to the new implementation, but I will find out as soon as I clone your repo and run my tests.
I agree that the TestCase is not really clean but I didn’t have much time to refactor it so I just added and amended what I needed.
So I’ll give freerunner a go and let you know
cheers
Simone
vizio
Hi Robert,
yeap I found the preReq and cleanUp really useful in my latest tests.
I really need to have a look at your freerunner the only thing I’m worried about is changing all my tests to conform
to the new implementation, but I will find out as soon as I clone your repo and run my tests.
I agree that the TestCase is not really clean but I didn’t have much time to refactor it so I just added and amended what I needed.
Little progress on my forked version of AsUnit
I managed to add a new preReq method and to amend the cleanUp method to be executed at the beginning of a TestCase and at the end, so before and after all the tests run.
I added them because I think, in some test cases, you want to prepare the field for the tests and then clean it up. For example you want to create some mock objects that are going to be used in more that one test and you don’t want to create/destroy them in each setUp/tearDown.
So the new TestCase sequence is
I also added the ability to handle async operations in all the states of the TestCase preReq/setUp/tearDown/cleanUp. In the previous version the tearDown and cleanUp didn’t handle async operations.
There was also a little gotcha in the original version of AsUnit, it didn’t consider the fact that some event callbacks can be too fast and it wasn’t picking them up correctly. To fix that I added new flags to double check if a state has finished processing async operations and so avoid calling the next state twice.
you can find the git repo here:
http://github.com/vizio360/asunit
UPDATE
I’m thinking to use RobertPenner ASUnit4 – FreeRunner and so abandonig my forked version of AsUnit3 , there’s no point in reinventing the wheel.
you can find his repo here:
http://github.com/robertpenner/asunit/tree/freerunner