Skip to content

Instantly share code, notes, and snippets.

@adamcameron
adamcameron / ttfOtherFunctionsTest.cfm
Last active May 19, 2022
TTF tests for misc functions that don't fit another category
View ttfOtherFunctionsTest.cfm
<cfscript>
void function run() {
describe("Tests of it", () => {
it("prefixes its message with ""It""", () => {
savecontent variable="message" {
it("IS A TEST MESSAGE", () => {})
}
tinyTest.results.pass--
expect(message).toInclude("It IS A TEST MESSAGE")
})
@adamcameron
adamcameron / tinyTestFramework.cfm
Last active May 18, 2022
A tiny testing framework to use with trycf.com
View tinyTestFramework.cfm
<style>
.tinyTest {background-color: black; color:white; font-family:monospace}
.tinyTest div {margin-left: 1em}
.tinyTest .pass {color:green;}
.tinyTest .fail {color:red;}
.tinyTest .error {background-color:red; color:black}
</style>
<cfscript>
tinyTest = {
@adamcameron
adamcameron / testHarness.cfm
Created May 18, 2022
Harness to pull in all the test Gists from github and then run them on trycf.com
View testHarness.cfm
<cfscript>
cfhttp(
method = "get",
url = "https://gist.githubusercontent.com/adamcameron/816ce84fd991c2682df612dbaf1cad11/raw/tinyTestFramework.cfm",
result = "frameworkCodeResponse",
throwOnError = true
);
frameworkCode = frameworkCodeResponse.fileContent;
@adamcameron
adamcameron / ttfMatcherFunctionsTest.cfm
Last active May 18, 2022
TTF tests for matcher functions
View ttfMatcherFunctionsTest.cfm
<cfscript>
void function run() {
describe("Tests of toBe", () => {
it("passes if the actual and expected values are equal", () => {
var actual = "TEST_VALUE"
var expected = "TEST_VALUE"
result = expect(actual).toBe(expected)
if (isNull(result) || !result) {
throw(type="TinyTest.TestFailedException")
@adamcameron
adamcameron / ttfLifeCycleFunctionsTest.cfm
Created May 18, 2022
TTF tests for lifecycle functions
View ttfLifeCycleFunctionsTest.cfm
<cfscript>
void function run() {
beforeAll(() => {
tinyTest.debug.setByBeforeAll = true
})
describe("Tests of beforeEach", () => {
describe("Tests without beforeEach (top)", () => {
result = []
it("was called before any usage of beforeEach", () => {
@adamcameron
adamcameron / AbstractBase.cfc
Created May 16, 2022
Jim Partin repro. Maybe. Dunno.
View AbstractBase.cfc
abstract component {
function init() {
writeOutput("AbstractBase init called<br>")
}
}
View testTinyTestFramework.cfm
<cfscript>
// tests
void function run() {
beforeAll(() => {
tinyTest.debug.setByBeforeAll = true
})
describe("Tests of TinyTestFramework", () => {
describe("Tests of it", () => {
it("prefixes its message with ""It""", () => {
View combinedTinyTestFrameworkAndTests.cfm
<style>
.tinytest {background-color: black; color:white; font-family:monospace}
.tinytest div {margin-left: 1em}
.tinyTest .pass {color:green;}
.tinyTest .fail {color:red;}
.tinyTest .error {background-color:red; color:black}
</style>
<cfscript>
tinyTest = {
@adamcameron
adamcameron / afterAllBasicTest.cfm
Created May 14, 2022
First test for afterAll functionality of TinyTestFramework
View afterAllBasicTest.cfm
<cfscript>
function run() {
afterAll(() => {
writeOutput("afterAll ran OK")
})
describe("Tests of afterAll", () => {
it("is a simple test", () => {
expect(true).toBeTrue()
})
@adamcameron
adamcameron / passingTestForTinyTestFramework.cfm
Created May 14, 2022
A test to load into the saved gist that has the framework loaded as setupcode in trycf.com
View passingTestForTinyTestFramework.cfm
<cfscript>
function run() {
describe("some tests", () => {
it("a passing test", () => {
expect(true).toBe(true)
})
})
}
tinyTest.runTests()