# IT:AD:Unit Testing/Automated:HowTo:Test N-Tier Apps # * [[../|(UP)]] {{indexmenu>.#2|nsort tsort}} * See also: [[IT/AD/NConfig/]] Developing Automated Unit Tests for N-Tier apps is an order more complex than the creation of tests for 3 Tier apps. ## Process ## Creating *Automated **Unit** Tests* of application tier services is relatively straight forward. It's done by remembering that Unit Tests are *never* Integration Tests, and Mock any services required. Creating *Automated **Integration** Tests* of application tier services is doable. the TestFixtureSetup or even TestSetup method has to create a new IoC Container before every test and invoke the application's boot strapping sequence, using a different ConnectionString and NConfig'ed settings.. Creating *Automated **Unit** Tests* of the Presentation Tier's services is done via mocking. Creating *Automated **Integration** Tests* of the Presentation Tier services -- which invoke the Application Tier's services using WCF or other cross-tier serialization protocol -- is much more complex. The App.Front.Tests integration tests have to: * Create two different IoC containers * The back tier's application has to be hosted within a test apphost console. * The back app has to have a ServiceHost for each service it is exposing. * Have to open up ports for each service: * `netsh http add urlacl url=http://+:80/MyServiceUri user=DOMAIN\user` * The front app has to start the back app. * Which will go through its startup sequence. * The front app has to shut down the console when done (for next test run). * That part is actually hard to do. * The console app can use a timer to shut itself down 60 seconds after its last call. ## Resources ##