|
From: Ian T. <Ia...@mo...> - 2008-08-26 09:24:19
|
Testing a command should be fine, but you should be mindful of its dependencies. Typically your command classes will invoke methods on other instances and you will want to assert that these methods have been called. If your command has dependencies on concrete classes, you will need to be able to access the instances of these classes within your fixture (test method). Remember that you only want to be testing the behavior of your class under test (i.e. your command class), not its dependencies (these should have their own unit tests). If the dependencies are 3rd party (or core) classes, you probably should be confident of their behavior. You either expect them 'just to work' OR they already have their own unit tests. Sometimes it's hard to assert the state of a dependency - this might be a sign of potential issues with your design. First step might be to refactor to interfaces or abstract classes. Alternatively you could just subclass your concrete class. If this all sounds too abstract, send me a copy of the class you want to test and I can give you an example (if you're worried about the sensitivity of the code, send it off list). Thanks, Ian ________________________________ From: asu...@li... [mailto:asu...@li...] On Behalf Of mudit tuli Sent: 25 August 2008 10:17 To: asu...@li... Subject: [Asunit-users] UnitTest a command in JumpShip framework ? Following from earlier comments by Ian Tyrrell -- >It's important to understand that ASUnit is a unit testing framework, >not an integration testing framework. > > It is designed to help verify behavior of a single unit of functionality > in your application, typically at single class/method level. > > It's not really appropriate if you want to test the end-to-end > functionality of your application. > >If you want to verify that when a user clicks a button a request is made >to the server, this would be an integration test. So, I am now focusing to unit-test individual components. I am using Jumpship framework : 1. The framework follows the Command Pattern 2. A controller function is called on command completion. Is it possible to unit-test a Command, or do I need to break down further? |