Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any framework for .NET to populate test data? [closed]

I am use c# and for unit testing and integration testing usually I need to populate fields automatically based on attributes.

Lets say we will test if we can write and get back user data to database.

  • I create a user object populate fields write user to database
  • Read user object from database
  • Check fields if what I write is same as what I read

Is there any framework to populate user with test data automatically and check if two object are have the same values?

Sample code may like this

User user = new User();
AutoPopulator.Populate(user);
user.Save();
like image 909
ilker Aksu Avatar asked Oct 22 '09 21:10

ilker Aksu


People also ask

What is the best test framework for .NET core?

xUnit test is the best Unit testing framework for . Net programming languages like C#, VB.Net, and F#. xUnit derives its structure and functionality from SUnit of Smalltalk.

How do I test .NET framework?

Use Registry Editor (older framework versions) From the Start menu, choose Run, enter regedit, and then select OK. You must have administrative credentials to run regedit. Open the subkey that matches the version you want to check. Use the table in the Detect .NET Framework 1.0 through 4.0 section.

Is .NET used for testing?

NET. Written by the original inventor of NUnit v2, xUnit.net is the latest technology for unit testing .


3 Answers

You might find it relevant. Here is a list of few other frameworks as of today:

Well-known and respected:

  • NBuilder
  • AutoFixture
  • AutoPoco(Discontinued / Deprecated)
  • Bogus - C# port of faker.js with locale support. Used by Elasticsearch (NEST).

Little-known:

  • Hydrator
  • Fabricator

Unfamiliar:

  • TestDataGenerator
  • TestDataFactory (Discontinued)
  • TestData
  • Any-.Net
like image 147
Igor Toporet Avatar answered Sep 28 '22 21:09

Igor Toporet


Take a look at NBuilder. It lets you build test objects with random data, incrementing values, and anything you can probably think of. All through a nice fluent interface.

like image 27
Michael Baldry Avatar answered Sep 27 '22 21:09

Michael Baldry


Yes there is. I found this when watching session #3 of the Summer of NHibernate series by Stephen Bohlen.

His company, Microdesk, has developed a utility that will allow you to save the state of a database on test fixture construction, set the state of the database at the start of every test, and recover the original state of the database on test fixture deconstruction.

Download the utility here: Microdesk.Utility.UnitTest

For a tutorial on how to use it, watch the Summer of NHibernate session #3 video.

like image 35
Ronnie Overby Avatar answered Oct 01 '22 21:10

Ronnie Overby