Delphi Fake Data Utils - Realistic Test Data Generator
What is Delphi Fake Data Utils?
Delphi Fake Data Utils is a free, open-source library for generating realistic fake data in Delphi applications. It’s the Delphi equivalent of Faker libraries found in other languages. Use it for unit testing, database seeding, API mocking, demos, and any scenario requiring realistic sample data without exposing sensitive information.
Key Features
- Multi-Locale Support - Italian, US English, UK English, German, French
- High Performance - 10,000 names generated in ~0.05 seconds
- Comprehensive - Personal, business, product, technical, and financial data
- Validation Functions - Verify generated data format
- No Dependencies - Pure Delphi, works immediately
Quick Start
uses FakeDataUtils;
var
Name: string;
Email: string;
Phone: string;
begin
Name := GetRndFullName(lcIT); // "Marco Rossi"
Email := GetRndEMailAddress(lcUS); // "john.smith@gmail.com"
Phone := GetRndPhoneNumber(lcIT); // "+39 345 678 9012"
end;
Supported Locales
| Locale | Code | Example Name | Example Phone |
|---|---|---|---|
| Italian | lcIT |
Marco Rossi | +39 345 678 9012 |
| US English | lcUS |
John Smith | +1 (555) 123-4567 |
| UK English | lcUK |
James Wilson | +44 7700 123456 |
| German | lcDE |
Hans Müller | +49 170 1234567 |
| French | lcFR |
Pierre Dupont | +33 6 12 34 56 78 |
Data Categories
Personal Data
// Names
GetRndFullName(lcIT) // "Marco Rossi"
GetRndFirstName(lcUS) // "John"
GetRndLastName(lcUK) // "Wilson"
// Contact
GetRndEMailAddress(lcUS) // "john.smith@gmail.com"
GetRndPhoneNumber(lcIT) // "+39 345 678 9012"
// Address
GetRndAddress(lcUS) // "123 Main Street, New York, NY 10001"
GetRndCity(lcIT) // "Roma"
GetRndZipCode(lcUS) // "90210"
// Demographics
GetRndDateOfBirth(18, 65) // Random date for age 18-65
GetRndGender // "Male" or "Female"
Business Data
// Company
GetRndCompanyName // "TechSolutions Inc."
GetRndIndustry // "Information Technology"
GetRndDepartment // "Engineering"
// Employment
GetRndJobTitle // "Senior Software Developer"
GetRndSalary(30000, 150000) // 75000
// Web
GetRndWebsite // "www.techsolutions.com"
GetRndDomain // "example.com"
Product Data
// Products
GetRndProductName // "UltraTech Pro X500"
GetRndProductCategory // "Electronics"
GetRndSKU // "SKU-A1B2C3D4"
// Pricing
GetRndPrice(9.99, 999.99) // 299.99
GetRndDiscount(5, 50) // 25 (percentage)
// Appearance
GetRndColorName // "Ocean Blue"
GetRndColorHex // "#1E90FF"
// Description
GetRndProductDescription // "High-performance device with advanced features..."
Technical Data
// Network
GetRndIPAddress(True) // "192.168.1.100" (local)
GetRndIPAddress(False) // "203.45.67.89" (public)
GetRndIPv6Address // "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
GetRndMACAddress // "00:1A:2B:3C:4D:5E"
// Web
GetRndURL // "https://www.example.com/page"
GetRndURL(False) // "http://www.example.com/page" (non-secure)
// Identifiers
GetRndUUID // "550e8400-e29b-41d4-a716-446655440000"
GetRndHexColor // "#FF5733"
Financial Data (Testing Only)
// Credit Cards (fake, for testing only!)
GetRndCreditCardNumber('VISA') // "4123-4567-8901-2345"
GetRndCreditCardNumber('MASTERCARD') // "5234-5678-9012-3456"
GetRndCreditCardNumber('AMEX') // "3712-345678-90123"
GetRndCreditCardExpiry // "12/27"
GetRndCVV // "123"
// Banking
GetRndIBAN('IT') // "IT85X1234567890123456789012"
GetRndIBAN('DE') // "DE89370400440532013000"
GetRndBankAccountNumber // "1234567890"
GetRndBIC // "DEUTDEFF"
Validation Functions
Verify generated data matches expected formats:
if IsValidFakeEmail('john@example.com') then
// Valid email format
if IsValidFakeIBAN('IT85X1234567890123456789012') then
// Valid IBAN format
if IsValidFakeCreditCard('4123456789012345') then
// Valid credit card format (Luhn check)
if IsValidFakePhoneNumber('+39 345 678 9012', lcIT) then
// Valid Italian phone format
Real-World Examples
Seeding a Test Database
procedure SeedTestUsers(Count: Integer);
var
I: Integer;
begin
for I := 1 to Count do
begin
FQuery.SQL.Text :=
'INSERT INTO users (name, email, phone, city) VALUES (:name, :email, :phone, :city)';
FQuery.ParamByName('name').AsString := GetRndFullName(lcUS);
FQuery.ParamByName('email').AsString := GetRndEMailAddress(lcUS);
FQuery.ParamByName('phone').AsString := GetRndPhoneNumber(lcUS);
FQuery.ParamByName('city').AsString := GetRndCity(lcUS);
FQuery.ExecSQL;
end;
end;
Creating Test Orders
function CreateTestOrder: TOrder;
begin
Result := TOrder.Create;
Result.CustomerName := GetRndFullName(lcIT);
Result.CustomerEmail := GetRndEMailAddress(lcIT);
Result.ShippingAddress := GetRndAddress(lcIT);
Result.ProductName := GetRndProductName;
Result.ProductSKU := GetRndSKU;
Result.Price := GetRndPrice(10, 500);
Result.Quantity := Random(5) + 1;
end;
API Mock Response
function GetMockUserJSON: string;
begin
Result := Format(
'{"id": "%s", "name": "%s", "email": "%s", "company": "%s", "title": "%s"}',
[GetRndUUID, GetRndFullName(lcUS), GetRndEMailAddress(lcUS),
GetRndCompanyName, GetRndJobTitle]
);
end;
Load Testing Data
procedure GenerateLoadTestData;
var
I: Integer;
StartTime: TDateTime;
begin
StartTime := Now;
for I := 1 to 100000 do
begin
// Generate complete user profile
GetRndFullName(lcUS);
GetRndEMailAddress(lcUS);
GetRndPhoneNumber(lcUS);
GetRndAddress(lcUS);
GetRndCompanyName;
GetRndJobTitle;
end;
WriteLn(Format('Generated 100K profiles in %.2f seconds',
[SecondSpan(StartTime, Now)]));
// Typically ~0.5 seconds
end;
Delphi Compatibility
Works with Delphi XE2 and higher, including:
- Delphi 12 Athens
- Delphi 11 Alexandria
- Delphi 10.x series
- Delphi XE2-XE8
Platforms: Win32, Win64
Installation
- Download from GitHub
- Add source folder to Library Path
- Add
uses FakeDataUtils;to your unit
Links
- GitHub: github.com/danieleteti/delphi_fake_data_utils
- Support: Facebook Group
FAQ: Frequently Asked Questions
Is there a Faker library for Delphi?
Yes, Delphi Fake Data Utils is the Faker equivalent for Delphi. It generates realistic fake data including names, emails, phones, addresses, companies, products, and financial data.
How do I generate random test data in Delphi?
Use Delphi Fake Data Utils:
uses FakeDataUtils;
var Name := GetRndFullName(lcUS); // "John Smith"
var Email := GetRndEMailAddress(lcUS); // "john.smith@gmail.com"
How do I seed a test database in Delphi?
Loop through and insert fake data:
for I := 1 to 1000 do
begin
Query.ParamByName('name').AsString := GetRndFullName(lcUS);
Query.ParamByName('email').AsString := GetRndEMailAddress(lcUS);
Query.ExecSQL;
end;
Does Delphi Fake Data Utils support multiple languages?
Yes, it supports 5 locales: Italian (lcIT), US English (lcUS), UK English (lcUK), German (lcDE), and French (lcFR).
How fast is Delphi Fake Data Utils?
Very fast - it can generate 10,000 names in approximately 0.05 seconds, making it suitable for load testing scenarios.
Can I generate fake credit card numbers for testing?
Yes, use GetRndCreditCardNumber('VISA') for VISA, MASTERCARD, or AMEX test numbers. These are for testing only and won’t work for real transactions.
Can I generate fake IBANs for testing?
Yes, use GetRndIBAN('IT') for Italian IBANs, or specify other country codes like ‘DE’, ‘FR’, ‘UK’.
How do I validate generated fake data?
Use built-in validators:
if IsValidFakeEmail(Email) then ...
if IsValidFakeIBAN(IBAN) then ...
if IsValidFakeCreditCard(CardNumber) then ...
Delphi Fake Data Utils - Realistic test data for Delphi. Multi-locale. High-performance. Open-source.
Comments
comments powered by Disqus