Utility library which helps Test Driven Development in Cycling '74 Max
This package works only in Max 8 or higher
- Test Driven Development
- “Test-First” approach in which unit tests are written before code or patcher
- See more at Wikipedia
- TDD means fewer bugs, higher quality software, and a razor focus.
- TDD allows problems to be detected as early as possible
- See more in this article
Use this command at your project root.
yarn add -D tdd-max
To use TDD-Max, you need to prepare two things, "test patcher" and "test code" Instead of setting up them manually, you can use our boilerplate with this command.
yarn tdd-max --init
You can pass an argument to indicate the destination path.
yarn tdd-max --init ./projects/test
You can make your test patcher as shown below. If you would like to use this as your boilerplate, this is accessible at boilerplate/test/test.maxpat
which is copied by the --init
command in the previous section.
Here is an example of how you can write your test codes.
// boilerplate/test/code/add1.test.js
const { expect } = require('chai');
const TARGET = 'add1';
test('adds 1 to input number', async () => {
expect(await fetch(TARGET, { add1: 3 })).to.equal(4);
expect(await fetch(TARGET, { add1: 0.1 })).to.equal(1.1);
expect(await fetch(TARGET, { add1: 100000 })).to.equal(100001);
expect(await fetch(TARGET, { add1: -2.1 })).to.equal(-1.1);
});
For more detailed guide, read the Getting Started
- Test codes should be named as
*.test.js
. - Test codes sould be placed in the same folder as your test patcher. You can also use subfolders.
-
tdd
will search those folders and load your codes automatically even if you have multiple test files.
If you'd like to use some assertion library such as 'chai', please be aware that those libraries should be installed to your project root, not to the folder where the TDD-Max is installed. Sending npm install chai
message to tdd
patcher will not work, so please use yarn add -D [package-name]
.
Though it is highly recommended to use yarn, you can manually install this library in case you are not familiar to that kind of dependency managers.
- Download zip file from release page
- Unzip
- Copy all the contents into a folder which is listed in your File Preference, such as
/Users/YourName/Documents/Max 8/Library
- Restart Max application if it is running.
Though you can file an issue, PR is much more appreciated. The code is simple enough to modify quickly.
- Node 10.16
- Yarn
- Max 8.1.0 or higher
- Clone this repository
- Add the path of your cloned directory to
Options >> File Preference
of your Max
- Indicate the version number in the
package.json
- commit and push
- run
npm publish
Tag will be automatically genearated