GSUnit

GSUnit is a Google Apps Script based testing framework based on JUnit by Kent Beck and JSUnit by Edward Hieatt. It will allow one to run tests while developing.

Project Key:  MIUhnnCDES0N3YHPEWX9DUtkh30YExdAc

function gsunit(){
  Logger.log(Gsunit.assertEquals('These should be equal', 5, 5));
  Logger.log(Gsunit.assertEquals('These are NOT equal', 5, 1));
}


assertEquals()

Checks that two values are equal (using ===) @throws GsUnit.Failure if the values are not equal @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assert()

Checks that the given boolean value is true. @throws GsUnit.Failure if the given value is not true @throws GsUnitInvalidAssertionArgument if the given value is not a boolean or if an incorrect number of arguments is passed

assertTrue()

Synonym for assertTrue @see #assert

assertFalse()

Checks that a boolean value is false. @throws GsUnit.Failure if value is not false @throws GsUnitInvalidAssertionArgument if the given value is not a boolean or if an incorrect number of arguments is passed

assertNotEquals()

Checks that two values are not equal (using !==) @throws GsUnit.Failure if the values are equal @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertNull()

Checks that a value is null @throws GsUnit.Failure if the value is not null @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertNotNull()

Checks that a value is not null @throws GsUnit.Failure if the value is null @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertUndefined()

Checks that a value is undefined @throws GsUnit.Failure if the value is not undefined @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertNotUndefined()

Checks that a value is not undefined @throws GsUnit.Failure if the value is undefined @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertNaN()

Checks that a value is NaN (Not a Number) @throws GsUnit.Failure if the value is a number @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertNotNaN()

Checks that a value is not NaN (i.e. is a number) @throws GsUnit.Failure if the value is not a number @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertObjectEquals()

Checks that an object is equal to another using === for primitives and their object counterparts but also desceding into collections and calling assertObjectEquals for each element @throws GsUnit.Failure if the actual value does not equal the expected value @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertArrayEquals()

Checks that an array is equal to another by checking that both are arrays and then comparing their elements using assertObjectEquals @throws GsUnit.Failure if the actual value does not equal the expected value @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertEvaluatesToTrue()

Checks that a value evaluates to true in the sense that value == true @throws GsUnit.Failure if the actual value does not evaluate to true @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertEvaluatesToFalse()

Checks that a value evaluates to false in the sense that value == false @throws GsUnit.Failure if the actual value does not evaluate to true @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertHashEquals()

Checks that a hash is has the same contents as another by iterating over the expected hash and checking that each key's value is present in the actual hash and calling assertEquals on the two values, and then checking that there is no key in the actual hash that isn't present in the expected hash. @throws GsUnit.Failure if the actual hash does not evaluate to true @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertRoughlyEquals()

Checks that two value are within a tolerance of one another @throws GsUnit.Failure if the two values are not within tolerance of each other @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

assertContains()

Checks that a collection contains a value by checking that collection.indexOf(value) is not -1 @throws GsUnit.Failure if the collection does not contain the value @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments are passed

assertArrayEqualsIgnoringOrder()

Checks that two arrays have the same contents, ignoring the order of the contents @throws GsUnit.Failure if the two arrays contain different contents @throws GsUnitInvalidAssertionArgument if an incorrect number of arguments are passed

fail(Object failureMessage)

Causes a failure

Arguments:

NameTypeDescription
failureMessageObjectthe message for the failure

pop( anArray)

Arguments:

NameTypeDescription
anArray