unit testing
quality
hard
impossible
Or is it?
Any system where the tests require complex setup or
where the tests run very slowly is basically untestable
bool IsFileEmpty(string file) {
var content = File.ReadAllText(file);
return content.Length == 0;
}
void FileExistsTest() {
File.Write("foo.txt", "");
var result = IsFileEmpty("foo.txt")
Assert.IsTrue(result);
}
public void ThrowIfEndOfTheWorld()
{
if (DateTime.Now == new DateTime(2000,1,1))
throw new Y2KBugException();
}
[DllImport("kernel32.dll")]
extern static bool SetSystemTime(ref SystemTime time);
[TestMethod]
public void Y2KTest()
{
SetSystemTime(2000,1,1,0,0,0);
Assert.Throws( () => ThrowIfEndOfTheWorld() );
}
unit testing
quality
not impossible.
improve your design.
http://www.microsoft.com/visualstudio/en-us
Somasegar’s Blog
http://blogs.msdn.com/b/somasegar/
http://blogs.msdn.com/b/jasonz/
http://www.facebook.com/visualstudio
http://twitter.com/#!/visualstudio
http://northamerica.msteched.com
www.microsoft.com/learning
http://microsoft.com/technet
http://microsoft.com/msdn
Descargar

Developer Tools, Languages & Frameworks