コード例 #1
0
        public void ValidateSpec()
        {
            var finder = new SpecFinder(new[] {GetType()});
            var builder = new ContextBuilder(finder, new DefaultConventions());

            ContextCollection result = new ContextRunner(builder, new MyFormatter(), false).Run(builder.Contexts().Build());

            if(result.Failures() == null)
            {
                Assert.Fail("*****   Failed to execute some tests   *****");
            }

            var crashes = result.AllContexts().Where(context => context.Exception != null).ToList();
            if(crashes.Any())
            {
                throw new SpecificationException("unknown", crashes.First().Exception);
            }

            if(result.Failures().Any())
            {
                throw new SpecificationException("unknown", result.First().Exception);
            }
        }