Giter VIP home page Giter VIP logo

wat's Introduction

THIS REPO IS NOT 4.0 COMPATIABLE!

Icon WAT

3.3.2

ko-fi

  1. Install
  2. Project Settings
  3. GUI
  4. CLI
  5. Example Tests
  6. Assertions

Install

  1. It is advised to download WAT from the Godot Asset Library.
  2. You may download WAT or WAT Mono from the release page.
  3. Extract the downloaded zip file.
  4. Add the addons folder from the extracted files to your Godot Project.
  5. Enable the Plugin in Project -> Project Settings -> Plugin Tab
  6. You should see a new "Tests" button in the bottom middle bar of the Godot Editor.

Project Settings

Once you have enabled the WAT Plugin, you will be able to see the settings in ProjectSettings -> General -> Wat (right at the bottom). If you don't see it, you may need to close the project settings and then re-open.

  • Test Directory

    The test directory is where WAT will look for your tests. It defaults to your project's root but it is suggested to use a dedicated tests folder. You can also use an absolute path external to your project (like "C:/Users/YourName/YourProject/Tests").

  • Results Directory

    The results directory is where WAT will store the results of your tests in JUnit Standard XML. It defaults to your project's root but it is suggested to store it inside your tests folder. This is usefulfor those of you who use Continous Integration (such as the github workflow action for WAT itself.)

  • Metadata Directory

    The metadata directory is where WAT will store metadata about your test scripts. Namely wheter they failed the last time and which tags they have been given. It defaults to your project's root but it is suggested to be stored in your test directory.

  • Tags

    You can add string tags to your test so that you can run tests that are split across different folders in a group. You define which tags can be added in this setting but you do the actual adding via the GUI.

  • Cache Tests

    Will avoid rescanning your test directory unless changes to them are detected. Disable this if you're using an external editor, since not all changes from an external editor are detected.

  • Window Size

    Defines the window size when running Tests.

  • Port

    This port is the port used for debugging tests. It is unlikely you'll need to change this often.

  • Display

    This defines wheter the Test Panel is stored in the bottom window or one of the many docks around Godot's Editor.

Graphical User Interface

Image

Top Left Menu ( Left To Right )

Run All Tests

Runs all tests directly in the Editor. WAT does not have access to the
debugger when run this way.

Note: A Rebuild might be required by any User who is using WAT Mono.

Debug All Tests

Runs all tests in the Scene. WAT does have access to the debugger when
run this way.

Select Tests

Users may select to Run (in editor) or Debug (in scene): previously failed tests, a set of tagged tests, a Directory, Script or a Method.

Note: Users may organize their tests into nested directories but this is only
for organizational purposes. WAT will *only* run the top-level tests of any directory.

Note: To edit the tags of a script, navigate to the script and then to Edit Tags. Check which tags you want the script to have (or uncheck those which you
don't want it to have)/

Filter Results

Users can choose to collapse all results, expand all results or expand only failures (which will collapse all results but expand the failed methods).

Repeat X Times

Users can choose to repeat a Test Run immediatly so many times. This can help
when testing erratic bugs where the problem only exists sometimes. Choose 0
to run the tests once.

Run on X Thread(s)

Users can set the count of threads to run their tests on (to the limit of their
processor core count - 1 for WAT itself otherwise it will stall).

Use 1 thread to not run on any additional threads.

Note: Do not use Repeats & Threads together. There is currently a bug.

Links

A Set of links that may or may not be useful to you.

Bottom Left Labels ( Left to Right )

Runs

The number of times tests have been run since WAT was open.

Total Tests

The number of total tests scripts ran in the previous Test Run.

Passed Tests

The number of total test scripts that passed in the previous Test Run.

Failed Tests

The number of total test scripts that failed in the previous Test Run.

Times

The time the Test Run is taking (or has taken if finished). This updates
live.

Command Line Interface

You can run tests in your command line interface by navigating to your Project Directory and executing the command: godot addons/cli.tscn [ARGUMENTS]

Run All Tests

godot addons/WAT/cli.tscn run=all

Run Directory

// Where X is the path of the directory you want to run
godot addons/WAT/cli.tscn run=dir+X

Run Script

// Where X is the project path of the script you want to run (Project Path meaning res:// path)
godot addons/WAT/cli.tscn run=res://script+X

Run Method

// Where X is the absolute path of the script where the method is contained
// and where Y is the name of the method
godot addons/WAT/cli.tscn run=method+X+Y

Run Failed

godot addons/WAT/cli.tscn run=failed

Run Tagged

// Where X is the name of the tag you want to run
godot addons/WAT/cli.tscn run=tag+X

Repeat Tests

godot addons/WAT/cli.tscn run=all repeat=2
OR
godot addons/WAT/cli.tscn run=all r=2

Note: Argument order does not matter so you can do this either
godot addons/WAT/cli.tscn r=2 run=all

Run on X Threads

godot addons/WAT/cli.tscn run=all thread=3
OR
godot addons/WAT/cli.tscn run=all t=3

Note: Argument order does not matter so you can do this either
godot addons/WAT/cli.tscn t=2 run=all

Examples

Assertions

wat's People

Contributors

aaronfranke avatar alexdarigan avatar atlinx avatar doctor-g avatar grafcube avatar jayman2000 avatar jummit avatar kersoph avatar olexatourko avatar paulhocker avatar paulmiller avatar railkill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wat's Issues

Broken tests are shown as success

Sometimes a test breaks and an error is produced. This also means the test never got to run so it has completed 0 of 0 test methods. Should add in a default fail state to handle this.

filesystem.gd returns paths with two forward slashes between directory and file name

Description

When filesystem._list is called, the paths that it returns are like res://path/to//filename.gd. This caused a few problems when I tried to load the templates to copy them.

Possible Fix

In filesystem.gd at line 27 -

var absolute_path: String = "%s/%s" % [path, name]

here, the / between the two %s could be removed, but when I tried that, WAT.tscn kept causing the editor to crash and the error message indicated cyclic reference.
The crashes happened if the addon was enabled, if the scene was opened or if the scene was run (in this case, only the preview window crashed).

Prevent Yields from holding tests up

Some scripts being tested may be waiting for a yield, some of these yields may never be called so we need a way to cancel them after an expected time.

Add Generic Creation Method

Basically sometimes you need to create an object to suit a purpose and that object needs data. We take in the object script/class, read what it needs, populate it, then return it back up to the test so it would read:

var object = _create_junk_object(object.klass)

Warnings Spam Output

Not an issue for me personally but it seems to spam the output of anyone using. Need to ignore everything with WAT itself manually with the #warning_ignore comments.

Autoloads Are Not Recognized When Running Tests

I have an Autoload Script that does not appear to be loading before the Tests begin to run. I am trying to create a sample project for you but I thought I would report it anyway first.

I will update this with more information when my sample project is ready for you.

Save Test Results

We should be able to save test results in a resource script (if toggled as an option). We can then further use these to track any differences between changes by comparing new results against previous ones. Possibly even adding a counter along with them.

Add Asserts that cancel tests on fail

Asserts, unlike expectations, will be used in fixtures (start, pre, post, end) to help ensure certain things are in place for all of the tests. If an assert fails, it will crash/skip the test script/method because the prerequisties are no longer in order.

Add Reset Plugin to clear dead data

When I mess with the UI elements of WAT (or sometimes testing servers) WAT goes crazy so I need to fix it via unload - reload. We should add a button to handle it automatically.

Capitalized folders on Linux.

I've just downloaded version 3.0 and got an error message while trying to run a test. It turns out that the script runner.gd had at line 7 the following code:

const COLLECT = preload("res://addons/WAT/runner/collect.gd")

I had to change it to:
const COLLECT = preload("res://addons/WAT/Runner/collect.gd")

Because of Linux. I see that in the newest commit code there is the same problem of capitalized paths.

Refactor Tree Display

This code is messy and unclear but I haven't figured a better way to name it yet due to its recursive nature. We could possibly add more implementation details to the result object instead of display.

Plugin Crashes When res://tests Directory Is Missing

Problem:

Trying to activate the Plugin without a tests folder in your project results in Godot crashing.

Recreate Problem:

  • Create a new Project
  • Import the Plugin using GIT (not asset library)
  • Activate the Plugin
  • You will receive the Error "res://tests missing"
  • Godot will Close

Workaround:

  • create the folder "tests" in the root of your project

  • activate the Plugin

  • create

Add Precondition Assert

The idea here is that some preconditions must be met before our primary assertion is. However we don't want to write:

asserts.thing(precondition)
execute_test():
asserts.thing(postcondition)

The typical way around this is to store the precondition state in a variable like this:

var precondition = object.method()
execute_test()
asserts.thing(precondition)
asserts.thing(postcondition)

What I could do is create a precondition interface. This would essentially show up similar to asserts but it would specifically only show on failure to avoid any cognitive overload.

check(precondition, "X must be true")
execute_test()
asserts(condition)

Alternatively we could have precondition crash the test there if it is required.

Add Logging System

Add a comprehensive optional logging system that logs everything correctly, outputs to the console and has different levels of output.

Master is now at 3.2 status

I'd imagine since 3.2 shouldn't be a breaking change, that master should just default to it instead of a separate branch. Keeping this here as a reminder.

Offer easy way to hit breakpoints in unit tests

Problem: Hitting a breakpoint in a unit-test is currently not possible through the WAT interface.

Potential solution: I suggest adding a "Debug selected X" button somewhere in the interface that would launch a godot scene running the selected tests (either script or directory, like the current interface)

This would allow the use of in-built godot breakpoints without the users having to create custom debugging scenes.

Easy to forget about resume calls after yield

Had a bug where my tests hung because I forgot to call "resume" after the yielded test method. Most obvious solution to this is to make a yield manager that stores yields, pop them on finish (and frees them) while also resuming if no yields left on test.

Possible Autoload Solution

See #32 and #42 for related discussions.

The primary issue with Autoloads is that they don't seem to be instanced during tests (and or on the same tree?) However we seem to be able to call:

EditorPlugin.new().add_autoload_singleton("AlreadyExistingName", "res://AutoLoad.gd")

With no issues and it works inside tests? On that note however, "remove_autoload" will take it away from the current test and the entire project too so avoid that.

stable is not stable

I've created a stable branch which does work but I don't consider it a true stable branch. This is just some prep for the next release. Once I have my first true release, I'll close this issue (which is only acting to serve as a reminder).

Double Inner Classes

This was too complicated to handle for the Alpha. It requires quite a bit of instancing/re-instancing and complicated parsing.

.... Progress Line hangs on Yielding.

When running tests, you will see a line go up and down in 10 dots. This works fine except for when we're yielding in code. One way is to maybe consider running it in a different thread but maybe other alternatives also exist.

Change Test Folder

Apologies if this exists somewhere but I did not see it, nor did I find on the Wiki.

Please add the ability to specify the root folder for test scripts. I have several project where the tests are located in folders called

my_project_tests
another_project_tests

this lets me keep things separated and organized.

Ideally this would be a modifiable somewhere in the Project Settings.

Add Command Line Interface

Add a CLI so people can run and see tests from their CL. Make sure to allow for windows, linux & mac.

WATemp is created on plugin load only

Trying to set up Docker/CI for WAT I ran into the issue of WATemp not existing. This is because it is only created when you load the plugin, not when you run the tests. Which causes problems with automated git hooked tests.

Running scene_director.test.gd causes Linux to segfault occassionally.

Sometimes when running the bootstrapped test scene_director.test.gd (either with other tests, its own directory or itself).

It seems this could be caused by trying to free an already freed reference OR by trying to remove a file too quickly/too many times.

It is a pretty specific issue so it probably isn't worth worrying too much overall so I'm just writing this issue to keep myself reminded of it in future.

Add Error Handling

Create a system to push errors and warnings to the Player. We should prefix the error with the source script + line along with the fact that it comes from WAT.

CLI Memory Output

When you run the CLI and use yields, it may complain about memory not being freed. This is likely because we are quitting once we're finished which isn't what the GUI does. Might require a simple check on PREDELETE NOTIFICATIONs.

Seperate Result Calculation from Display.

Right now we calculate a number of things about result lists in the display script itself which leads to an odd, somewhat recursive-lite style code that can be confusing.

Instead we could maybe create a middle-man script that stores all of that data in a struct.

Add Test Subdirectories

Add an option for additional subdirectories being tested. This allows for different series of tests to be run for different circumstances. The more obvious example would be integration, end-to-end style of tests.

Also need to consider directories within directories, if the first dir is for the test type, the sub-subdirs will be for different configurations.

Run All/Run Dir buttons freeze (animation only)

The first time you load the editor, the run all or run dir buttons seem to freeze (This is probably due to loading resources). They also seem to intermittently freeze up occasionally.

This is animation only. Their functions don't freeze (thankfully).

Implement Fluent Assertions

Basically change expectations that exist now to fluent assertions.

ie

asserts.has(value, container, context)

we would do

asserts.collection(collection).has(item).give_context("string")

or something like that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.