Skip to content
Prayag edited this page May 22, 2023 · 5 revisions

What is Unit Testing?

Unit Testing key concepts

  1. Interactions

While an interaction looks similar to a regular method invocation, it is simply a way to express which method invocations are expected to occur.

doSome is interaction.

class A {
   B b;

   String doSome() {
       Data bData = b.doSome()
       //domeSomething with bData
        return something;
   }
}
  1. Interaction cardinality

how often a method call is expected, can be 0 or *.

class A {
   B b;

   String doSome() {
       Data bData = b.doSome(args1)
       Data cData = b.doSome(cargs1)
       //domeSomething with bData
        return something;
   }
}
  1. Target cardinality

which dependency object is expected to receive the method call

  1. Arguments constraints
class A {
   B b;
   C c;

   String doSome() {
       Data bData = b.doSome(args1)
       Data cData = c.doSome(cargs1)

       return bData + cData;
   }
}
  • b.doSome is invoked with args1
  • c.doSome is invoked with cargs1

Unit Testing Standards

https://github.com/prayagupa/java-tdd#ut-practices

Clone this wiki locally