0

Don't know if this is right title for what I need. I need to run program with same input data few times and ensure that every time program take exactly the same path and produced exactly the same output. I even need to make sure that some iterator proccessed elements in same order.

Maybe there is some tools for that purpose? Or maybe there is some standard way what-to-do in order to check that? I put C# in tags because I need solution specifically for that language (and I'm coding in VS2012 if that can be of any help).

Edit: Input of my program consists of list of integers and output is simple boolean. Even if I'll write tests - there can be very big difference in calculations and yet same result. I especially need to check that program code taken the same path every time.

bobby
  • 617
  • 1
  • 8
  • 19
  • Vs2012 has Tesing framework. Write you program logic as a method and test it. http://msdn.microsoft.com/en-us/library/hh270865.aspx – Sriram Sakthivel Aug 26 '13 at 06:48
  • Input of my program consists of list of integers and output is simple boolean. Even if I'll write tests - there can be very big difference in calculations and yet same result. – bobby Aug 26 '13 at 06:50
  • What do you think would be the sources on non-deterministic behaviour in your code? – Dirk Aug 26 '13 at 06:53
  • @Dirk Dictionaries maybe or uninitialized variables somewhere. – bobby Aug 26 '13 at 06:54
  • @bobby C# doesn't allow uninizialized variables. How would dictionaries be non-deterministic? Do you require a specific order of items? – Dirk Aug 26 '13 at 06:55
  • @Dirk Yes, things can go wrong if order is changed. – bobby Aug 26 '13 at 06:56
  • @bobby There is an [OrderedDictionary](http://msdn.microsoft.com/en-us/library/system.collections.specialized.ordereddictionary.aspx) class in the .NET framework. – Dirk Aug 26 '13 at 06:58
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/36224/discussion-between-dirk-and-bobby) – Dirk Aug 26 '13 at 06:59

1 Answers1

0

You can use test framework and use mocks with excepts and asssert the output

Daniel Rapaport
  • 375
  • 2
  • 18
  • Can you please check first post? I added info why I think that test will not work. – bobby Aug 26 '13 at 06:52
  • you can run on the same input over and over again and see that the path is the with mocks and the output with asserts i can't understand the problem. – Daniel Rapaport Aug 26 '13 at 08:57