Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarincak committed Jul 9, 2020
0 parents commit 16911c6
Show file tree
Hide file tree
Showing 45 changed files with 1,600 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Paige Marincak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
157 changes: 157 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# gms2-test
Unit Testing Framework for Gamemaker Studio 2.3+

## Table of Contents

1. [Requirements](#requirements)
2. [Download](#download)
- [Local Package](#local-package)
- [Marketplace](#marketplace)
3. [Maintainers & Contribution](#maintainers--contribution)
4. [Samples](#samples)
5. [API](#api)
- [Helpers](#helpers)
- [Matchers](#matchers)
- [Test Definitions](#test-definitions)
6. [Unit Testing Resources](#unit-testing-resources)

## Requirements

|| Supported Version |
|--|--|
| Gamemaker Studio 2 | v23.1.1.160 |

## Download
### Local Package

1. Download the [exported local package](https://github.com/pmarincak/gms2-test/blob/master/export/package.gmltest.yymps)
2. Select Tools > Import Local Package
3. Navigate to the saved package and select import
4. Import all resources

### Marketplace

TBD

## Maintainers & Contribution
This package is maintained by [Paige Marincak](https://twitter.com/paigemarincak/). To contribute, please fork the repo and make pull requests.

## Samples
Samples can be viewed [here](https://github.com/pmarincak/gms2-test/tree/master/samples).

## API
### Helpers
#### gmltest_start
Start running the unit tests

#### gmltest_set_deterministic
Sets the seed to a static value or a random value. Can be toggled.

@param {Bool} deterministic Whether to set the seed to a static value or not

### Matchers
#### gmltest_expect_eq
Expects that the actual value is equal to the expected value

@param {*} expected
@param {*} actual

#### gmltest_expect_false
Expects that the provided value is false

@param {*} value

#### gmltest_expect_true
Expects that the provided value is true

@param {*} value

#### gmltest_expect_gt
Expects that the actual value is greater than the expected value

@param {*} expected
@param {*} actual

#### gmltest_expect_lt
Expects that the actual value is less than the expected value

@param {*} expected
@param {*} actual

#### gmltest_expect_neq
Expects that the actual value is not equal to the expected value

@param {*} expected
@param {*} actual

#### gmltest_expect_not_null
Expects that the provided value is not null

@param {*} value

#### gmltest_expect_null
Expects that the provided value is null

@param {*} value

### Test Definitions
#### GMLTest_Harness
Base struct that all harnesses should extend from

///@description Called before the execution of the test.
/// Use this function to setup your fixtures and parameterized tests.
function setup(){
// Override this function
}

///@description Called after the execution of the test.
/// Use this function to clean up your fixtures and parameterized tests.
function tear_down(){
// Override this function
}
#### test
Register a basic test with a name and a function to execute

@param {String} name The name of the test to be logged to the console
@param {Function} fn The function to be executed
#### xtest
Disable a registered basic test that has a name and a function to execute

@param {String} name The name of the test to be logged to the console
@param {Function} fn The function to be executed
#### test_f
Register a fixture test with a harness, name and a function to execute

@param {Struct} harness The struct to use as the harness when the test executes
@param {String} name The name of the test to be logged to the console
@param {Function} fn The function to be executed

#### xtest_f
Disable a registered fixture test that has a harness, name and a function to execute

@param {Struct} harness The struct to use as the harness when the test executes
@param {String} name The name of the test to be logged to the console
@param {Function} fn The function to be executed

#### test_p
Register a parameterized test with a harness, name, array of parameters, and a function to execute

@param {Struct} harness The struct to use as the harness when the test executes
@param {String} name The name of the test to be logged to the console
@param {Array} array An array containing a list of parameters to be executed using the same provided function
@param {Function} fn The function to be executed which takes one parameter

#### xtest_p
Disable a registered parameterized test that has a harness, name, array of parameters, and a function to execute

@param {Struct} harness The struct to use as the harness when the test executes
@param {String} name The name of the test to be logged to the console
@param {Array} array An array containing a list of parameters to be executed using the same provided function
@param {Function} fn The function to be executed which takes one parameter

## Unit Testing Resources
The following are a list of resources that can assist you with writing your unit tests.

- [What is unit testing?](https://en.wikipedia.org/wiki/Unit_testing)
- [What is a fixture?](https://en.wikipedia.org/wiki/Test_fixture)
- [Beginner's Guide to Unit Testing](https://www.codementor.io/@wbsimms/unit-testing-foundations-programming-beginners-du107q81d)
Binary file added export/package.gmltest.yymps
Binary file not shown.
50 changes: 50 additions & 0 deletions samples/BasicSample/BasicSample.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions samples/BasicSample/objects/MyObject/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = "hello";
33 changes: 33 additions & 0 deletions samples/BasicSample/objects/MyObject/MyObject.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions samples/BasicSample/options/html5/options_html5.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions samples/BasicSample/options/linux/options_linux.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions samples/BasicSample/options/mac/options_mac.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions samples/BasicSample/options/main/options_main.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 16911c6

Please sign in to comment.