Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxFaker Library 1

Status
Not open for further replies.

Irwin1985

Programmer
Feb 2, 2017
44
0
0
ES
Hi everybody

I've released a class library that fakes data for you. This is really useful when you're implementing n-tier architecture, 3-layer, or just isolate the business logic and data access layer.


NOTE: you may combine FoxFaker with FoxUnit and FoxMock for a better performance.



Basic Usage:

[pre]
Public Faker
Faker = NewObject("FoxFaker", "FoxFaker.prg")
?Faker.fakeName() && Jhon Doe
[/pre]


Hope you really enjoy it like I do.

Thanks!

Irwin R.
 
Thanks for contributing this, Irwin. I guess what you call "fake data" is what we used to call "test data"? If so, this sort of thing can save a lot of tedious work.

I have a vague memory of Tamar producing something similar way back when, and writing about it in FoxPro Advisor. I've also created a simple test data generator myself, but I expect it is nothing like as sophisticated as yours.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

Correct. It's a test data generator and really can save a lot of tedious work.

regards


A team is only pieces that you exchange until you finish the work, it is efficient, it works.
 
Irwin - Maybe I misunderstood (I haven't looked hard), but my impression is what you've provided is a generator that can give a particular test data item on the fly. It's designed specifically to work in a testing environment like unit testing.

What I wrote years ago was a framework to let you create a test database, which is a whole different thing.

Am I getting it right?

Tamar
 
Hi Tamar,

You're in the right way, FoxFaker generate random test data that can be used on unit testing by filling in your business logic objects:

Consider these examples:

Code:
Procedure test_should_save_a_record_in_table_returns_true

   oPerson.FirstName = Faker.fakeName('female')
   oPerson.LastName  = Faker.fakeLastName()
   oPerson.Age       = Faker.fakeNumberBetween(18, 50)
   oPerson.Email     = Faker.fakeEmail()

   This.AssertTrue(oPerson.Save(), "something went wrong")
   
*=================================================

Off course it can be used in different way like filling forms in presentation layer:

Code:
Procedure btnFillData.Click
   With Thisform
      .txtFirstName.Value = Faker.fakeName('female')
      .txtLastName.Value  = Faker.fakeLastName()
      .txtAge.Value       = Faker.fakeNumberBetween(18, 50)
      .txtEmail.Value     = Faker.fakeEmail()
   EndWith
EndProc

Or populating records in a table:

Code:
Select People
For i=1 To 50 Step 1
   Append Blank
   Replace FirstName With Faker.fakeName('female')
   Replace LastName  With Faker.fakeLastName()
   Replace Age       With Faker.fakeNumberBetween(18, 50)
   Replace Email     With Faker.fakeEmail()
EndFor
Browse




A team is only pieces that you exchange until you finish the work, it is efficient, it works.
 
Right, so it's for on-the-fly test data generation, not like the tool that I built, which is for creating a test data set that you might, for example, distribute with an application. Whole different purpose and very handy.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top