Is there a specification-based testing environment for C # .Net 2.0?

For example, Reductio (for Java / Scala) and QuickCheck (for Haskell). Such an infrastructure, which I think of, will provide β€œgenerators” for the built-in data types and allow the programmer to define new generators. The programmer will then define a test method that claims a property by accepting variables of the corresponding types as parameters. Then the structure generates a bunch of random data for the parameters and runs hundreds of tests of this method.

For example, if I implemented the Vector class and it had the add () method, I could verify that my addition commutes. So I would write something like (in pseudocode):

boolean testAddCommutes(Vector v1, Vector v2) { return v1.add(v2).equals(v2.add(v1)); } 

I could run testAddCommutes () on two specific vectors to find out if this addition commutes. But instead of writing a few calls to testAddCommutes, I am writing a procedure, which generates arbitrary vectors. Given this, the environment can run testAddCommutes on hundreds of different inputs.

Does this allow someone to call?

+4
source share
4 answers

There's FsCheck, a port from QuickCheck to F # and thus C #, although most of the document seems to be for f #. I also studied ideas myself. see http://kilfour.wordpress.com/2009/08/02/testing-tool-tour-quicknet-preview/

+4
source

I also can not understand correctly, but PEX may come in handy.

+1
source

to elaborate on my previous remark, the QN code for checking the pseudocode example will look something like this:

  new TestRun (1, 1000)
     .AddTransition (new MetaTransition <Input <Vector, Vector>, Vector>
     {
         Name = "Vector Add",
         Generator = DoubleVectorGenerator,
         Execute = input => input.paramOne.Add (input.paramTwo)
     }
     .RegisterProperty (
         (input, output) =>
             new QnProperty (
                 "Is Communative",
                 () => QnAssert.IsTrue (output == input.paramTwo.Add (input.paramOne))
             )
         )
     )
     .Verify ()
     .RethrowLastFailureifAny ()
     .ReportPropertiesTested (new ConsoleReporter ());

where DoubleVectorGenerator is a user-defined class that sets values ​​of type Input <Vector, Vector>.

+1
source

I may not have understood you correctly, but check this ...

http://www.ayende.com/projects/rhino-mocks.aspx

-1
source

Source: https://habr.com/ru/post/1276775/


All Articles