Bot releases are hidden (Show)
Published by bitwes over 5 years ago
assert_null
and assert_not_null
simulate
to the test object so you no longer have to use gut
when calling it. It is fine if you still do though. Sorry if this breaks something.double
method is now smart:
double_scene
anymore but it remains.var MyClass = load('res://my_class.gd')
var MyClassDouble = double(MyClass)
double
Inner Classes by passing an Inner Class path like so:
double('res://my_script.gd', 'Inner1/InnerInInner1/AndSoOn')
after_all
on inner classes that are skipped.Published by bitwes almost 6 years ago
res:\\
when using doubling.Published by bitwes about 6 years ago
maximize
method.Issue 83: Added option to include subdirectories. Thanks to ChemicalInk for doing the initial work to implement the traversals. The option is off by default so that it doesn't break anything. This will probably change in later releases.
Issue 69: Renamed some methods. The old names will remain but the documentation has been updated to reflect the new names. If I ever end up removing the old names they will become deprecated for awhile and then removed in some later release.
assert_get_set_methods
renamed to assert_accessors
b/c it is easier to sayassert_extends
renamed to assert_is
b/c the keyword changed in gut 3.0The setup/teardown methods got a rename so they are a little easier to understand. You should use the new names going forward, but refactoring existing tests can be messy (see note below).
prerun_setup
renamed to before_all
setup
renamed to before_each
postrun_teardown
renamed to after_all
teardown
renamed to after_each
Note about setup/teardown rename:
super
's setup/teardown methods. For example, if you rename super
's setup
to before_each
but all the test classes that inherit from it are still calling .setup
then you'll have problem on your hands.Published by bitwes over 6 years ago
-gpo
command line option to print out all option values from all sources and what value would be used when running Gut. This will make debugging theses issues easier later.assert_almost_eq(got, expected, error_interval, text='')
- Asserts that got
is within the range of expected
+/- error_interval
. The upper and lower bounds are included in the check. Verified to work with integers, floats, and Vector2. Should work with anything that can be added/subtracted. Examples
assert_almost_ne(got, expected, error_interval, text='')
- This is the inverse of assert_almost_eq
. This will pass if got
is outside the range of expected
+/- error_interval
. Examples
-gpo
command line option to print out all option values from all sources and what value would be used when running Gut. This will make debugging option issues much easier.Some housekeeping. Removed some commented out and unreachable code. Renamed a lot of tests in test_test.gd
since it now uses Inner Test Classes which allows for better names. They were setting a bad example for PRs.
Published by bitwes over 6 years ago
I've "dog food"ed the doubles, stubs, and spies more in my own game and I think they are pretty stable. This release contains some tweaks to doubles and stubs and the introduction of spies as well as some other testing goodness.
inner_class_name
option for editor node, command line, and .gutconfig.json.assert_exports
: Assert that script exports a variable with a specific type. Thanks Myrkrheim
0
when all tests pass and 1
if there are any failures. Thanks cmfcmf.
.gutconfig.json
file. That one is also thanks to Myrkheim.assert_called
assert_not_called
assert_call_count
Published by bitwes over 6 years ago
First, the Readme has been broken up into a Github wiki. I think this will make consuming the help easier. There is probably some room for improvement in the documentation and organization. Create issues for anything that could be done better.
You can now create "Inner Classes" that run tests. This allows you to breakup your tests and create multiple setup/teardown scopes in a single script.
Example:
extends "res://addons/gut/test.gd"
class TestInnerClass:
extends "res://addons/gut/test.gd"
func setup():
pass
class TestInnerClass2:
extends "res://addons/gut/test.gd"
func setup():
pass
There is now support for a config file for the command line tool. It only supports some options right now, but that will be expanded in the future.
{
"dirs":["res://test/unit/", "res://test/integration/"],
"should_exit":true,
"ignore_pause":true,
"log": 3
}
There are also two new experimental features in this release. Doubling and Stubbing. These are experimental because their implementation could change a lot. I hope not, but they might. I fought with how these should work a lot, and honestly, I might have gotten it wrong. So I'm going to put it out there and see how they get used in the wild. I'm dedicated to keeping these features and improving on them, but they might be a little rough around the edges.
You can find out more about Stubbing and Doubling in the Wiki.
Published by bitwes over 6 years ago
assert_string_contains
assert_string_starts_with
assert_string_ends_with
assert_has_method
gut_tests_and_examples
and everything will be right in the world. Thanks cmfcmf.Published by bitwes over 6 years ago
gut_tests_and_examples
so that there was less stuff to uncheck when installing via the in-engine Asset Library. I'm still not 100% happy with the setup.addons/gut/
so that it is distributed with the addon and doesn't accidently get copied into the root of some other project when installed via the Asset Library.simulate
to call _physics_process
instead of _fixed_process
in the 3.0 conversion. Fixed that.signal_watcher
could try to disconnect from a freed object.yield_to
which allows you to yield
to a signal or a maximum amount of time. This keeps your tests moving along if you yield to a signal that never gets emitted. Now the test will fail after an amount of time instead of sitting in limbo forever. This will also watch the signals on the object so you can make asserts about signals after the yield
and you can save a line of code.# wait for my_object to emit the signal 'my_signal'
# or 5 seconds, whichever comes first.
yield(yield_to(my_object, 'my_signal', 5), YIELD)
assert_signal_emitted(my_object, 'my_signal', \
'Maybe it did, maybe it didnt, but we still got here.')
Published by bitwes over 6 years ago
Gut is now compatible with Godot 3.0. The Godot2.x compatible version can be found in the godot_2x
branch.
Published by bitwes about 7 years ago
watch_signals
was not working with "Script Signals". These are signals defined using the syntax signal SomeSignal
instead of using add_user_signal
to create them.Published by bitwes about 7 years ago
This version mostly contains some long overdue house cleaning. So that this wasn't JUST a reorganization release I also added an method for asserting instance type and inheritance and some minor tweaks.
This change should only affect really old tests. If you started using Gut later than 4.0 then you will most likely be ok. The best approach to adjusting your tests is just to run them and see if it tells you that you are calling any methods that have been moved and then fixing them by removing the gut.
prefix.
Due to the restructuring I've completely moved the various asserts
out of the core gut
object and put them in the test
object that all unit tests inherit from. This means that any asserts or pending calls that are prefixed with gut.
need to have the gut.
prefix removed. To cut down on the annoyance level of this change I've added stubs for the removed methods that fail with a message indicating that the method has been moved.
Published by bitwes over 7 years ago
watch_signals
Gut will monitor any signals emitted by the object. You can then later make assertions about whether or not a signal was emitted or whether it emitted a desired number of times, and even if it was emitted and passed specific parameters. The following methods were added for this feature, see the README for more information about them.
watch_signals
assert_signal_emitted
assert_signal_not_emitted
assert_signal_emitted_with_parameters
assert_signal_emit_count
assert_has_signal
get_signal_emit_count
get_signal_parameters
gut.p
str
on the input. So if you pass it an object or something that isn't a string it won't blow up.Published by bitwes over 7 years ago
It is a plugin now! Unfortunately that means some things and paths have changed.
Before upgrading, remove gut.gd and gut_cmdln.gd from your your current project. That will help ensure that you got everything setup right with the new install location.
res://addons/gut
. So you'll want to clean out wherever you had it previously installed.res://addons/gut/test.gd
.assert_has(obj, element, text)
- Asserts that the object passed in has
the element passed in. Works with any object that has a has
method. Useful for testing the contents of arrays and hashes.assert_does_not_have(obj, element, text)
- The inverse of assert_has
.Published by bitwes over 7 years ago
The Run button will now run the currently selected script and all scripts after it. This helps workaround the fact that you cannot catch errors that kill the program. I've found it useful when you go to run all your tests but one script blows up somewhere in the middle of the list. You can continue testing the rest to find out if you have anymore issues without having to do them one at a time.
A new button was added next to the dropdown that will only run the selected script.
I removed the strict type checking when comparing Floats and Integers. Since it really doesn't matter if you compare 1 with 1.0 and 1.1 does not equal 1 I removed it. It will print out a warning whenever you do a comparison of a Float and an Integer but it no longer fails the test.
end_test
when yieldingIn a stroke of genius (or lack or foresight) I realized that Gut could detect the end of a yield
whenever an assertion was made. Now, as long as you use one of the assert methods or pending after a yield
, you don't have to call end_test
. You still can, it won't hurt anything, but you don't have to.
If I did this right, the bugs fixed should be listed somewhere through the magic of Github. If not, then I'll add a list here.
Published by bitwes about 8 years ago
The biggest changes were to organization and documentation and the repo is now on Github instead of Bitbucket. Some methods have been wrapped/moved/renamed to cut down on typing and to improve readability.
Nothing has been removed though and this release is completely backwards compatible with earlier versions. There is one caveat though. This release introduces strict datatype comparisons that will cause tests to fail if you are comparing two things that aren't of the same datatype. This feature can be disabled but read the section in the readme before you do.
Also some default locations for scripts have changed as far as documentation and the command line tool are concerned. See the install instructions for more details. You will need to specify the location of the gut.gd
script in the options for the command line tool if you do not change to the new default.
yield_for
.The gut.zip file below contains all the files in the test/gut directory. If you have made changes to your gut_main.gd or gut_main.scn then do not copy these files over yours.