Tag Archives: TestNG

TestNG with Parameters

Often we want to test a function against a set of variables.

TestNG offers @DataProvider annotation.

My goal is to test a service class method: findByType of class StateMachineObjectService. This method accepts two ENUM arguments: SmProcess process and SmState state.

I need to feed a collection of different processes and states. Best way is to create an object array with desired combinations and feed it to test function:

Output is like:

ADVERTISE INCOMPLETE
Hibernate: select statemachi0_.id as id1_22_, statemachi0_.process as process2_22_, statemachi0_.state as state3_22_ from sm_map statemachi0_ where statemachi0_.process=0 and statemachi0_.state=0

ADVERTISE ACTIVE
Hibernate: select statemachi0_.id as id1_22_, statemachi0_.process as process2_22_, statemachi0_.state as state3_22_ from sm_map statemachi0_ where statemachi0_.process=0 and statemachi0_.state=1

===============================================
Custom suite
Total tests run: 8, Failures: 0, Skips: 0
===============================================