70 likes | 187 Vues
This document illustrates various test cases for evaluating a mail template using test-driven development. It covers the evaluation of templates such as "Hello, ${name}" with the value "Reader" resulting in "Hello, Reader". It also details scenarios where missing or undefined variables lead to errors, like raising a MissingValueError when no value is provided. Additional performance verification includes testing a template with 20 variables to ensure evaluation occurs within 200 milliseconds. This is essential for maintaining template engine performance.
E N D
TDD Example Test Driven – Koskela Chapter 2
Mail Template Test List • Evaluating template “Hello, ${name}” with the value “Reader” for variable “name” results in the string “Hello, Reader”. • Evaluating template “${greeting}, ${name}” with the values “Hi” and “Reader”, respectively, results in the string “Hello, Reader”. • Evaluating template “Hello, ${name}” with values “Hi” and “Reader” for variables “doesnotexist” and “name”, respectively, results in the string “Hello, Reader” • Evaluating template “Hello, ${name}” with no value for variable “name” raises a MissingValueError. • Verify that a template of 100 words and 20 variables with values of approximately 15 characters each is evaluated in 200 milliseconds or less. • Evaluate template “${one}, ${two}, ${three}” with values “1”, “${foo}”, and “3”, respectively, and verify that the template engine renders the result as “1, ${foo}, 3”.
Mail Template Test List • Evaluating template “Hello, ${name}” with the value “Reader” for variable “name” results in the string “Hello, Reader”. • Evaluating template “${greeting}, ${name}” with the values “Hi” and “Reader”, respectively, results in the string “Hello, Reader”. • Evaluating template “Hello, ${name}” with values “Hi” and “Reader” for variables “doesnotexist” and “name”, respectively, results in the string “Hello, Reader” • Evaluating template “Hello, ${name}” with no value for variable “name” raises a MissingValueError. • Verify that a template of 100 words and 20 variables with values of approximately 15 characters each is evaluated in 200 milliseconds or less. • Evaluate template “${one}, ${two}, ${three}” with values “1”, “${foo}”, and “3”, respectively, and verify that the template engine renders the result as “1, ${foo}, 3”.
Mail Template Test List • Evaluating template “Hello, ${name}” with the value “Reader” for variable “name” results in the string “Hello, Reader”. • Evaluating template “${greeting}, ${name}” with the values “Hi” and “Reader”, respectively, results in the string “Hello, Reader”. • Evaluating template “Hello, ${name}” with values “Hi” and “Reader” for variables “doesnotexist” and “name”, respectively, results in the string “Hello, Reader” • Evaluating template “Hello, ${name}” with no value for variable “name” raises a MissingValueError. • Verify that a template of 100 words and 20 variables with values of approximately 15 characters each is evaluated in 200 milliseconds or less. • Evaluate template “${one}, ${two}, ${three}” with values “1”, “${foo}”, and “3”, respectively, and verify that the template engine renders the result as “1, ${foo}, 3”.
Mail Template Test List • Evaluating template “Hello, ${name}” with the value “Reader” for variable “name” results in the string “Hello, Reader”. • Evaluating template “${greeting}, ${name}” with the values “Hi” and “Reader”, respectively, results in the string “Hello, Reader”. • Evaluating template “Hello, ${name}” with values “Hi” and “Reader” for variables “doesnotexist” and “name”, respectively, results in the string “Hello, Reader” • Evaluating template “Hello, ${name}” with no value for variable “name” raises a MissingValueError. • Verify that a template of 100 words and 20 variables with values of approximately 15 characters each is evaluated in 200 milliseconds or less. • Evaluate template “${one}, ${two}, ${three}” with values “1”, “${foo}”, and “3”, respectively, and verify that the template engine renders the result as “1, ${foo}, 3”.
Mail Template Test List • Evaluating template “Hello, ${name}” with the value “Reader” for variable “name” results in the string “Hello, Reader”. • Evaluating template “${greeting}, ${name}” with the values “Hi” and “Reader”, respectively, results in the string “Hello, Reader”. • Evaluating template “Hello, ${name}” with values “Hi” and “Reader” for variables “doesnotexist” and “name”, respectively, results in the string “Hello, Reader” • Evaluating template “Hello, ${name}” with no value for variable “name” raises a MissingValueError. • Verify that a template of 100 words and 20 variables with values of approximately 15 characters each is evaluated in 200 milliseconds or less. • Evaluate template “${one}, ${two}, ${three}” with values “1”, “${foo}”, and “3”, respectively, and verify that the template engine renders the result as “1, ${foo}, 3”.
Mail Template Test List • Evaluating template “Hello, ${name}” with the value “Reader” for variable “name” results in the string “Hello, Reader”. • Evaluating template “${greeting}, ${name}” with the values “Hi” and “Reader”, respectively, results in the string “Hello, Reader”. • Evaluating template “Hello, ${name}” with values “Hi” and “Reader” for variables “doesnotexist” and “name”, respectively, results in the string “Hello, Reader” • Evaluating template “Hello, ${name}” with no value for variable “name” raises a MissingValueError. • Verify that a template of 100 words and 20 variables with values of approximately 15 characters each is evaluated in 200 milliseconds or less. • Evaluate template “${one}, ${two}, ${three}” with values “1”, “${foo}”, and “3”, respectively, and verify that the template engine renders the result as “1, ${foo}, 3”.