Wednesday, 15 February 2012

tdd - C# test always return true even when test fails -


Before I was running my test, I had set my code to look like the following: < / P>

  Private bool ValidateAntone (EntityModel.MultiIndexEntities Reference) {If (context.SearchDisplayViews.Count ()! = Expected SdvCount) {Assert.Fail ("Search Performance View Number Was Different from What Was Expected" ); } If (sdv.VirtualID! = Expected SedvertIID) {Assert.Fail ("Search Display View Virtual ID was different than what was expected"); } If (sdv.EntityType! = Expected SDETTip) {Assert.Fail ("What was the type of search display visual unit different than what was expected"); } Back true; }  

It also tells the correct path that if any exam passes or fails, and after some advice, I have changed my code, so it looks like the following :

  Private EntityModel.MultiIndexEntites context {Assert.AreEqual (Expected antiquity, context.), "What was the entity count different than expected"); Back true; }  

My thinking on using the new assert.rerequal is that it will still return on the basis of true or false if it passes or fails . But now my test is always right because I have no way to test if my test failed or not

All of the following line is named in my main examination method: < / P>

  Depend on ISTRU (test4PassFail = Accredited Test ("4.4"), "Test 4");  

Is there any way i can change my new code to return true or false without returning my old code?

instead of correcting , you can do . (Expected Antique, Context.NT.Count () "); .

This will be your failure / pass. You do not have to make a comeback, but as such, Time true is returning.

  [test class] public class test {[TestMethod] Private Zero valid Teston (EntityModel.MultiIndexEntites reference) {Assert.AreEqual ( Expected Antiquity, Context. Antiques.Count (), "Entity Count Was Different From Expect");}}  

No comments:

Post a Comment