xunit extensibility

36
xUnit.net Extensibility Brad Wilson Jim Newkirk

Upload: erica

Post on 14-Feb-2016

108 views

Category:

Documents


0 download

DESCRIPTION

xUnit.net Extensibility. Brad Wilson Jim Newkirk. Schedule. Assert Extensibility9:00 Before/After Extensibility9:45 Fact Extensibility10:15 BREAK10:45 Fixture Extensibility11:00 Runner Extensibility11:30 Putting it all Together11:45. Assert Extensibility. - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation

xUnit.net ExtensibilityBrad WilsonJim NewkirkScheduleAssert Extensibility9:00Before/After Extensibility9:45Fact Extensibility10:15BREAK10:45Fixture Extensibility11:00Runner Extensibility11:30Putting it all Together11:45Assert ExtensibilityNot Easy to Add New AssertsLimitations of the platform & languageProvide core assertions with the frameworkKeep assert language consistentNo differentiation between failure and exceptionsCustomization of ComparisonsIEquatable / IEqualityComparerAssert.ContainsAssert.EqualIComparable / IComparerAssert.InRangeFallback for Contains & EqualAsserts that Return ValuesWhen type is testedAssert.IsAssignableFromAssert.IsTypeAssert.ThrowsWhen collections are testedAssert.SingleException catcherRecord.ExceptionExampleCompare dates without timesExerciseFinish by 9:45Before/After ExtensibilityDesignCross-cutting concernsReusable attributeInitializing environmentCleaning up after stateful testsRuns regardless of test outcomeHas no access to test class or methodUnspecified order (compose for guarantee)ExampleRollback databaseBrainstorming ExerciseFinish by 10:15Fact ExtensibilityDesignAnswers: What is a test method?Enumeration of testsExecution of testsMetadata (skip, timeout, display name)Why?Metadata changesI want all my tests to have a timeoutI want the display name of my test to be something other than method nameEnumeration changesI want this test method to be run many times, perhaps with different input values for each runExecution changesI want to do something different than just running the method with no parametersExample[Theory] attributeExerciseFollowed by break, back by 11:00Fixture ExtensibilityIUseFixtureShare reusable fixture setup and teardownConstructorDisposeMost frameworks encourage base classes hereLack of multiple inheritance in the CLRInherit to be reused, not to reuseExampleTest data seed & cleanupITestClassCommand and RunWithAnswers: What is a test class?Pre- and post-fixture behaviorPre- and post-test behaviorTest class creation & cleanupTest method discoveryTest method orderingExampleRemove RandomizationExerciseFinish by 11:30Runner ExtensibilityDesignVersion resilient runner APIsLink against xunit.runner.utility.dll, not xunit.dllTest assembly lives in a separate app domainAssemblyConfiguration File(Optional) Shadow CopyLow-Level APIExector (remote)ExecutorWrapper (local)On the wire, its:XML as a string (for status)Boolean continue flag (to cancel)Dont use this. High-Performance APIThin wrapper on top of ExecutorWrapperTestRunnerTestRunnerResultIRunnerLoggerCracks the XML into simple valuesNot stateful; callback is mandatoryRunners: MSBuild, TD.NET, ResharperObject-Oriented APIObject model on top of ExecutorWrapperMultiAssemblyTestEnvironmentTestAssembly, TestClass, TestMethodTestStatusITestMethodRunnerCallbackCracks the XML into objectsStateful; callback is optionalRunners: Console, GUIProject files (.xunit)One or more assembliesOutput types & locationsFiltersExamplexunit.consolePutting it all TogetherExampleBDD with [Observation]ExampleBDD with SubSpecExampleAmalga Best Practice AnalyzerExerciseThank You!http://xunit.codeplex.com/@bradwilson @jamesnewkirk @xunit