how to create test data
TRANSCRIPT
How to CreateTest Data
Hideshi Ogoshi YNS Philippines Inc.
Aug-11-2016
Why do we test?
• Check if a software satisfies its requirements.
How to satisfy requirements
• Prepare sufficient test cases
• Prepare sufficient data
• Test properly
What is the ideal test data?
• The data, which satisfies all the patterns
• Called exhaustive testing (ISTQB)
What is better test data
• If we can provide the data for all the patterns, it would assure higher quality.
• In a realistic view, there would be time limitation.
• We should eliminate some data in order to finish the testing to meet the deadline without decreasing the quality.
How to create data
• If add / edit / delete features are already provided, it’s much better to use it.
• If not, it has to be created manually.
Example• Requirements
• An article must belongs to an author
• An article can be favored by users
• Should display article.title, author.name, number of favorites, article.open_day with descending order on article.open_day
• If the article is open and not deleted and not future
• If the author is not deleted
• If the favorite exists or and not deleted
Table definitionsarticle author favorite
id id id
name name article_id
author_id deleted user_id
open
open_day
deleted
SQLSELECT article.title , article.open_day , author.name , COUNT(favorite.id) AS number_of_favorites FROM article INNER JOIN author ON author.id = article.author_id LEFT OUTER JOIN favorite ON favorite.article_id = article.id WHERE article.open = 1 AND article.deleted = 0 AND article.open_day <= CURDATE() AND author.deleted = 0 GROUP BY article.title, article.open_day, author.name ORDER BY article.open_day DESC
Number of patterns• article is open / not open => 2
• article is deleted / not deleted => 2
• article open_date is past / today / future => 3
• author is deleted / not deleted => 2
• number of favorite is 0 / 1 / 2 => 3
• number of patterns is 2 x 2 x 3 x 2 x 3 = 72
Demo
Benefits• Pursue higher quality
• Help you to do test driven development
Table design tips• For the higher testability
• Do not use foreign key
• Do not use NOT NULL constraint
Thank you