Skip to content

v3.0.0

Compare
Choose a tag to compare
@AlexDarigan AlexDarigan released this 23 Jun 19:52
3a401cf

Changelist

  • Runner now collects any script within the test folder if it extends from WATTest

  • You can now run single folders or scripts (this includes only running tests from the top level test folder)

  • Added expect.is_freed & expect.is_not_freed

  • Added expect.file_exists & expect.file_does_not_exist

  • Added signal_was_emitted_with_args (where args is position-specific array)

  • Added expect.is_x & expect.is_not_x where X is any builtin non-object type such as integers or Arrays. (expect.is_built_in_type is deprecated)

  • New Setting File located in WAT/Settings/Config.tres (Change this and then overwrite it
    on save to update settings via Godot's save resource button)

  • You can now use output(msg: String) in test scripts to print to the output panel

Inline Data

You can now repeat a test_method with the use of the parameters function or an expectation with the use
of the expect.loop method:

New Method: Parameters

The Parameter method is used when you want to use the same test but for different data. Use it at the
start of the test method that you want to repeat, passing it a 2D Array. The values of the first inner array are the keys you will be using to access the values. All of the other inner arrays are the data sets. When you want to access the parameters in your test, us p.[key] where key is one of the values in the array of keys. If you use a non-string key, use p.get(key) instead.

e.g

func test_addition():
    parameters([["a", "b", "c"], [5, 5, 10], [2, 2, 4], [7, 10, 12]])
    expect.is_equal(calculator.add(p.a, p.b), p.c, "%s + %s == %s" % [p.a, p.b, p.c])

is equivalent to

func test_addition():
    expect.is_equal(calculator.add(5, 5,), 10, "5 + 5 == 10")
    expect.is_equal(calculator.add(2, 2), 4, "2 + 2 == 4")
    expect.is_equal(calculator.add(7, 10), 12, "7 + 10 == 12")

When executed, you get:

(Note: The first time you call parameters, it sets the keys, the times after that, it just updates them)

New Method: loop

expect.loop allows you to do the same as above except with the expectation data. This can be helpful if only a subset of the data is varied. To use expect loop, pass the name of the
actual expect method you want to use along with a 2D Array of data sets (none of these should
be for keys, that is handled implicitly)

e.g

func test_addition():
    var calc = Calculator.new()
    var data = [[calc.add(5, 5), 10, "5 + 5 == 10"], [calc.add(2, 2), 4, "2 + 2 == 4"], [calc.add(7, 10), 12, "7 + 10 = 12"]]
    expect.loop("is_equal", data)

When executed, you get this:

Crashing Tests

You can now crash any test during its start method by passing in CRASH_IF_TEST_FAILS* at the end of any expect method. When a test crashes, the runner will dispose of it immediately and start the next test. Crashed Tests show up in the output
with a hazard warning icon:

(*This is a simple aliased const true bool).

Partial Doubles

You can now partially double scripts. Previously when doubled, scripts would lose all implementation. If you partially double a script it will default to its base implementation until you use default or stub on it. Currently, you can't reverse
this process. This is useful when you only want to stub a specific method out, like a shuffle mechanic, to make games more deterministic while keeping everything else in place.

Settings

  • Set main test folder (defaults to "res://tests")
  • Include test Subdirectories (when running tests)
  • Show subdirectories as separate tabs (if including subdirectories in tests)
  • Set list of valid test script prefixes (If used, only the tests with these prefixes will be run)
  • Set test method prefix (This must be set. Only methods with this prefix will be executed)
  • Keep Parameter's type when creating test doubles
  • Keep Return Value's type when creating test doubles
  • Exclude Void Return Value's when creating test doubles (Only applicable when keeping return value types)
  • Set Double Strategy to Partial

UI Updates

  • Redesigned UI to make use of TabContainer/Tabs
  • Added Icons for Passed, Failed & Crashed Tests
  • Added Timer that tracks total elapsed time of tests in (minutes : seconds : milliseconds)