Steven,
I haven't tested this but you should be able to create a mock implementation of IBuildEngine and assign that to the BuildEngine property of your custom task. This class is responsible for dealing with logging so you could redirect the log messages as appropriate or add assertions for your tests. Regards, William From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Nagy Sent: Friday, 9 May 2008 4:17 PM To: [email protected] Subject: [OzTFS] Custom Tasks : Unit Tests hi all (again), For custom MSBuild tasks, I find it easy to create unit tests. Something like this: [TestMethod] public void TestCreateGuid() { Microsoft.Sdc.AU.Common.tasks.Common.CreateGuid task = new Microsoft.Sdc.AU.Common.tasks.Common.CreateGuid(); task.Format = "N"; Assert.IsTrue(task.Execute()); Assert.AreEqual<int>(32, task.Output.Length); } (this test is based on Grant Holliday's CreateGuid task here: http://ozgrant.com/2008/04/04/createguid-msbuild-task/) The downside is that most Tasks use the logger to log info messages, or exceptions, etc. I was wondering if there was a way to clear the log handler? It seems pretty embedded and unlike standard Trace logger stuff (which would easily let me clear the handler so that it didn't output anywhere, or even better, output somewhere different in the case of unit tests). Any ideas? Cheers, Steve ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ OzTFS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. View the web archives at http://www.mail-archive.com/[email protected]/ Powered by mailenable.com, supported by www.readify.net OzTFS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. View the web archives at http://www.mail-archive.com/[email protected]/ Powered by mailenable.com, supported by www.readify.net
