OJTestCase Class Reference

A single test case. More...

List of all members.

## Public Member Functions

(void) | - assert:equals:`[implementation]`
(void) | - assert:equals:message:`[implementation]`
(void) | - assert:matches:`[implementation]`
(void) | - assert:notEqual:`[implementation]`
(void) | - assert:notEqual:message:`[implementation]`
(void) | - assert:notSame:`[implementation]`
(void) | - assert:notSame:message:`[implementation]`
(void) | - assert:same:`[implementation]`
(void) | - assert:same:message:`[implementation]`
(void) | - assertFalse:`[implementation]`
(void) | - assertFalse:message:`[implementation]`
(void) | - assertNoThrow:`[implementation]`
(void) | - assertNotNull:`[implementation]`
(void) | - assertNotNull:message:`[implementation]`
(void) | - assertNull:`[implementation]`
(void) | - assertNull:message:`[implementation]`
(void) | - assertThrows:`[implementation]`
(void) | - assertTrue:`[implementation]`
(void) | - assertTrue:message:`[implementation]`
(int) | - countTestCases`[implementation]`
(CPString) | - description`[implementation]`
(void) | - fail`[implementation]`
(void) | - fail:`[implementation]`
(void) | - failEqual:actual:message:`[implementation]`
(void) | - failNotEqual:actual:message:`[implementation]`
(void) | - failNotSame:actual:message:`[implementation]`
(void) | - failSame:actual:message:`[implementation]`
(OJTestResult) | - run`[implementation]`
(void) | - run:`[implementation]`
(void) | - runBare`[implementation]`
(void) | - runTest`[implementation]`
(void) | - setUp`[implementation]`
(void) | - tearDown`[implementation]`

## Detailed Description

A single test case.

A single test case. This is an abstract superclass that each of your test cases (which are usually in their own separate files and of which each tests one and only one class) should subclass. Each of these test cases have the ability to run seperately.

Example:

OJMoqTest : OJTestCase

... // tests and other files

In order to increase readability, there is a conventional way of writing tests. Each test should be prepended by the word "test" and non-tests should not be prepended by the word "test".

Example:

- (void)testThatOJMoqDoesInitialize {} // a test
- (OJMoq)createStandardOJMoqInstance {return nil;} // a non-test

Before each test, the message "setUp" will be passed to your test. By default, this does nothing but you can override the "setUp" method to do something for your test.

After each test, the message "tearDown" will be passed to your test. By default, this does nothing but you can override the "tearDown" method to do something for your test.

Definition at line 3 of file OJTestCase+Assert.j.

## Member Function Documentation

- (void) assert: |  | (id) | expected
equals: |  | (id) | actual
|  |  | `[implementation]`

assertions

assert that the expected value is equal to the actual value

Parameters:

  expected | The expected value
  actual | The actual value

Definition at line 63 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
equals: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the expected value is equal to the actual value and not equal then report the given message

Parameters:

  expected | The expected value
  actual | The actual value
  message | The failure message

Definition at line 78 of file OJTestCase+Assert.j.

- (void) assert: |  | (CPString) | aRegex
matches: |  | (CPString) | aString
|  |  | `[implementation]`

assertions

assert that the given Regular Expression matches the given string

Parameters:

  aRegex | A string that represents a regular expression (e.g. "^(.*)$")
  aString | The string to test the regular expression against

Definition at line 256 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
notEqual: |  | (id) | actual
|  |  | `[implementation]`

assertions

assert that the expected value is not equal to the actual value

Parameters:

  expected | The expected value
  actual | The actual value

Definition at line 91 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
notEqual: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the expected value is not equal to the actual value and if equal then report the given message

Parameters:

  expected | The expected value
  actual | The actual value
  message | The failure message

Definition at line 106 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
notSame: |  | (id) | actual
|  |  | `[implementation]`

assertions

assert that the expected object and the actual object are not the same object.

Parameters:

  expected | The expected value
  actual | The actual value

Definition at line 147 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
notSame: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the expected object and the actual object are not the same object. If they are the same, then report the given message.

Parameters:

  expected | The expected value
  actual | The actual value
  message | The failure message

Definition at line 162 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
same: |  | (id) | actual
|  |  | `[implementation]`

assertions

assert that the expected object and the actual object are the same object.

Parameters:

  expected | The expected value
  actual | The actual value

Definition at line 119 of file OJTestCase+Assert.j.

- (void) assert: |  | (id) | expected
same: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the expected object and the actual object are the same object. If they are different, then report the given message.

Parameters:

  expected | The expected value
  actual | The actual value
  message | The failure message

Definition at line 134 of file OJTestCase+Assert.j.

- (void) assertFalse: |  | (BOOL) | condition | `[implementation]`

assertions

assert that the given condition is false

Parameters:

  condition | The condition to verify

Definition at line 37 of file OJTestCase+Assert.j.

- (void) assertFalse: |  | (BOOL) | condition
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the given condition is false and if not false then report the given message

Parameters:

  condition | The condition to verify
  message | The failure message

Definition at line 50 of file OJTestCase+Assert.j.

- (void) assertNoThrow: |  | (Function) | zeroArgClosure | `[implementation]`

assertions

assert that the zero argument closure that is given does not throw an exception.

Parameters:

  zeroArgClosure | The zero argument closure that will be run.

Example:

[self assertNoThrow:function(){[myObject myMessage:myArgument];}];

Definition at line 227 of file OJTestCase+Assert.j.

- (void) assertNotNull: |  | (id) | object | `[implementation]`

assertions

assert that the given object is not null.

Parameters:

  object | The given object

Definition at line 198 of file OJTestCase+Assert.j.

- (void) assertNotNull: |  | (id) | object
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the given object is not null. If it is null, report the given message.

Parameters:

  object | The given object
  message | The failure message

Definition at line 211 of file OJTestCase+Assert.j.

- (void) assertNull: |  | (id) | object | `[implementation]`

assertions

assert that the given object is null

Parameters:

  object | The given object

Definition at line 174 of file OJTestCase+Assert.j.

- (void) assertNull: |  | (id) | object
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the given object is null. If it is not null, report the given message.

Parameters:

  a | parameter

Definition at line 186 of file OJTestCase+Assert.j.

- (void) assertThrows: |  | (Function) | zeroArgClosure | `[implementation]`

assertions

assert that the zero argument closure that is given does throw an exception.

Parameters:

  zeroArgClosure | The zero argument closure that will be run.

Example:

[self assertThrows:function(){[myObject myMessage:myArgument];}];

Definition at line 243 of file OJTestCase+Assert.j.

- (void) assertTrue: |  | (BOOL) | condition | `[implementation]`

OJAssertions

assert that the given condition is true

Parameters:

  condition | The condition to verify

Definition at line 12 of file OJTestCase+Assert.j.

- (void) assertTrue: |  | (BOOL) | condition
message: |  | (CPString) | message
|  |  | `[implementation]`

assertions

assert that the given condition is true and if it is not report the given message

Parameters:

  condition | The condition to verify
  message | The failure message

Definition at line 25 of file OJTestCase+Assert.j.

- (int) countTestCases |  |  | `[implementation]`

The number of test cases this represents.

Returns:
  1

Definition at line 109 of file OJTestCase.j.

- (CPString) description |  |  | `[implementation]`

Definition at line 114 of file OJTestCase.j.

- (void) fail |  |  | `[implementation]`

assertions

Fails the test case.

Definition at line 266 of file OJTestCase+Assert.j.

- (void) fail: |  | (CPString) | message | `[implementation]`

assertions

Fails the test case and reports the given message.

Parameters:

  message | The failure message

Definition at line 278 of file OJTestCase+Assert.j.

- (void) failEqual: |  | (id) | expected
actual: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

Definition at line 293 of file OJTestCase+Assert.j.

- (void) failNotEqual: |  | (id) | expected
actual: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

Definition at line 298 of file OJTestCase+Assert.j.

- (void) failNotSame: |  | (id) | expected
actual: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

Definition at line 288 of file OJTestCase+Assert.j.

- (void) failSame: |  | (id) | expected
actual: |  | (id) | actual
message: |  | (CPString) | message
|  |  | `[implementation]`

Definition at line 283 of file OJTestCase+Assert.j.

- (OJTestResult) run |  |  | `[implementation]`

Runs the tests and returns the result.

Definition at line 46 of file OJTestCase.j.

- (void) run: |  | (OJTestResult) | result | `[implementation]`

Informs the OJTestResult to run the tests

Parameters:

  result | The OJTestResult that will run the tests

Definition at line 57 of file OJTestCase.j.

- (void) runBare |  |  | `[implementation]`

Runs the setup, test and teardown for the

Parameters:

  a | parameter

Definition at line 66 of file OJTestCase.j.

- (void) runTest |  |  | `[implementation]`

If the selector is not null,

Parameters:

  a | parameter

Definition at line 83 of file OJTestCase.j.

- (void) setUp |  |  | `[implementation]`

SetUp method that is called before each run.

Definition at line 93 of file OJTestCase.j.

- (void) tearDown |  |  | `[implementation]`

TearDown method that is called after each run.

Definition at line 100 of file OJTestCase.j.

The documentation for this class was generated from the following files:

- Frameworks/OJUnit/OJTestCase+Assert.j
- Frameworks/OJUnit/OJTestCase.j

All Classes Files Functions Variables