Unit testing where you depend on implementation of another method I am implementing a gap buffer and am trying to write a test for the insert method, the test currently looks something like this:

gapBuffer.insert('a')
assertEquals(gapBuffer.getText(), "a")
gapBuffer.insert('c')
assertEquals(gapBuffer.getText(), "ac")
gapBuffer.insert('d')
assertEquals(gapBuffer.getText(), "acd")
gapBuffer.moveCursorTo(1)
gapBuffer.insert('d')
assertEquals(gapBuffer.getText(), "abcd")


Now the problem is that this method is not just testing the insert method because it depends on the correctness of the getText() and moveCursorTo() methods

Note: the getText() and moveCursorTo() methods are not trivial but do have tests of their own
It's usually hard to test a setter without a getter and vice versa. Back Door Manipulation in xUnit Test Patterns discuss this in detail.

Some smells from the same book/site: 


Eager Test: A single test verifies too much functionality. 
Missing Assertion Message: A test fails. Upon examining the output of the Test Runner, we cannot determine exactly which assertion had failed.


I'd create at least three tests from the one above:

@Test
public void testInsert() {
    gapBuffer.insert('a')
    assertEquals(gapBuffer.getText(), "a")
}

@Test
public void testInsertTwice() {
    gapBuffer.insert('a')
    gapBuffer.insert('c')
    assertEquals(gapBuffer.getText(), "ac")
}

@Test
public void testMoveCursorToAndInsert() {
    gapBuffer.insert("acd")
    gapBuffer.moveCursorTo(1)
    gapBuffer.insert('d')
    assertEquals(gapBuffer.getText(), "abcd")
}


It helps Defect Localization.