Various types of test data are required to perform testing activities. MAQS has utility called Faker Data that provide the ability to generate random and valid data during runtime.
You would be able to get an understanding about faker data utility after going through following code segments.
1. Getting Current System time
Code Segment
[TestMethod] public void FakeDataDate() { var dateTime= FakerData.GenerateInstantSpecificTime(); Console.WriteLine(dateTime); }
2. Generate Unique id – Not formatted
Code Segment
[TestMethod] public void FakeDataUniqueIDNotFormatted() { var uniqueID = FakerData.GenerateUniqueId(false); Console.WriteLine(uniqueID); }
3. Generate Unique id – Formatted
Code Segment
[TestMethod] public void FakeDataUniqueIDFormatted() { var uniqueID = FakerData.GenerateUniqueId(); Console.WriteLine(uniqueID); }
4. Generate Phone Number – Formatted
Code Segment
[TestMethod] public void FakeDataPhoneNumberFormatted() { var phoneNumber = FakerData.GenerateUSPhoneNumber(); Console.WriteLine(phoneNumber); }
5. Generate Phone Number – Not Formatted
Code Segment
[TestMethod] public void FakeDataPhoneNumberNotFormatted() { var phoneNumber = FakerData.GenerateUSPhoneNumber(true); Console.WriteLine(phoneNumber); }
6. Generate Social Security Number – With Dashes
Code Segment
[TestMethod] public void FakeDataSocialSecurityNumberWithDashes() { var socialSecurityNumber = FakerData.GenerateSocialSecurityNumber(true); Console.WriteLine(socialSecurityNumber); }
7. Generate Social Security Number – Without Dashes
Code Segment
[TestMethod] public void FakeDataSocialSecurityNumberWithoutDashes() { var socialSecurityNumber = FakerData.GenerateSocialSecurityNumber(); Console.WriteLine(socialSecurityNumber); }
8. Generate Random value from the list
Code Segment
[TestMethod] public void FakeDataRandomNumber() { List<string> valueList = new List<string> { "AAA","BBB","CCC"}; var randomListValue = FakerData.GeneralRandomizer(valueList); Console.WriteLine(randomListValue); }
You can try out above sample code segments when writing automation code. These methods are useful for generating random sample data required for automated test execution.
This functionality is being deprecated because there is something the MAQS team likes a lot more.
ReplyDeletehttps://www.nuget.org/packages/Faker.Data/
This was created by the dev originally responsible for the MAQS faker code. Has all the functionality that MAQS has + some really nice extras.