• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/15

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

15 Cards in this Set

  • Front
  • Back

fixture


  • to create a set of objects initialized to certain states
  • ensure that there is a well known and fixed environment in which tests are run so that results are repeatable
  • Examples of fixtures:
  • Loading a database with a specific, known set of data
  • Copying a specific known set of filesPreparation of input data
  • Setup/creation of fake or mock objects

annotation to check for an exception

@Test(expected= IndexOutOfBoundsException.class)

assertArrayEquals() method


  • will test whether two arrays are equal to each other (same values)
  • assertArrayEquals(expectedAry,resultAry);

The assertEquals() method


  • compares two objects for equality, using their equals() method
  • assertEquals(expected,result);
  • has overloaded option to compare primitive values as well


assertThat() method


  • compares an object to an org.hamcrest.Matcher
  • assertThat("this string", is("this string"));
  • assertThat(123, is(123));.

Chanining Matcher

assertThat(123, not( is(345) ) );

Core matchers


  • any() - Matches anything
  • is() - object equality
  • describeAs() - adds a descrip


Logical matchers (Hamcrest)


  • allOf() - Takes an array of matchers, and all matchers must match the target object
  • anyOf() - Takes an array of matchers, and at least one of the matchers must report that it matches the target object
  • not() - Negates the output of the previous matcher.

2 key goals of jUnit

  • to make developers write tests for once!
  • to make tests that are valid over time

tests must be leveraged

must be written so new tests can use the original tests

Fluent Builder Test Pattern


  • Person testPerson =
  • new PersonBuilder() .SetFirstName("Jason") .SetLastName("Fauchelle") .Build();
  • only really used for unit testing and constructors with lots of parameters

Database Test Pattern


  • The easiest way to test databases is throught the use of an ORM!!
  • Hibernate!
  • when ORM not an option use database mocking framework
  • https://dzone.com/articles/unit-testing-patterns-common-patterns-to-follow-fo
  • great referencel on combing builder pattern with ORM

A fake


  • is our own implementation that functions just enough for the unit tests to work.

A mock

is an object that we can setup with hard-coded responses to various method calls.

order tests run

random