Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.03 KB

23-test-code.md

File metadata and controls

54 lines (42 loc) · 1.03 KB

<<back

Test code

Let's test code using teuton.

Example:

  • Ask students to make a program that performs addition and multiplication.
  • Define targets sum and mul:
# File: start.rb
group "Test code example" do
  # Reading filepath from config file
  filepath = "./#{get(:folder)}/#{get(:filename)}"

  target "Sum"
  run "#{filepath} 3 4"
  expect [ "Sum", "7" ] # Using Array/List of required items

  target "Mul"
  run "#{filepath} 3 4"
  expect /Mul\s+=\s+12/ # Using a regular expresion
end
  • Define config params:
# File: config.yaml
---
global:
  folder: examples/23-test-code/code
cases:
- tt_members: student_1
  filename: math_1.py
- tt_members: student_2
  filename: math_2b.py
  • Put students files into code folder.
  • Now run Teuton test:
❯ teuton examples/23-test-code

CASE RESULTS
+------+-----------+-------+-------+
| CASE | MEMBERS   | GRADE | STATE |
| 01   | student_1 | 100.0 | ✔     |
| 02   | student_2 | 100.0 | ✔     |
+------+-----------+-------+-------+