Sha256: 117044797ace495a5605f4621634c87ad16e05bc3c4672d5e94e7223bca0ca2e

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

[<<back](README.md)

# 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`:

```ruby
# 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:

```yaml
# 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 | ✔     |
+------+-----------+-------+-------+
```

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
teuton-2.9.2 docs/learn/23-test-code.md
teuton-2.9.1 docs/learn/23-test-code.md
teuton-2.9.0 docs/learn/23-test-code.md
teuton-2.8.0 docs/learn/23-test-code.md
teuton-2.7.3 docs/learn/23-test-code.md
teuton-2.7.2 docs/learn/23-test-code.md
teuton-2.7.1 docs/learn/23-test-code.md
teuton-2.7.0 docs/learn/23-test-code.md
teuton-2.6.0 docs/learn/23-test-code.md
teuton-2.5.0 docs/learn/23-test-code.md
teuton-2.4.5 docs/learn/23-test-code.md
teuton-2.4.4 docs/learn/23-test-code.md
teuton-2.4.3 docs/learn/23-test-code.md
teuton-2.4.2 docs/learn/23-test-code.md