Monday, 15 June 2015

java - Data-driven tests with jUnit -


What do you use to write data-driven tests in jUnit?

(My Definition) Data-driven Examination is an examination that reads data from some external source (file, database, ...), per line / file / whatever executes a test, and Displays the results in a test runner as you have different tests - the result of each run is displayed separately, not in a huge total.

In JUnit4 you can use teststars to perform data-driven tests.

This is not very well documented, but the original idea is annotated with a static method ( @Parameters ) that gives collection of object arrays. Each of these arrays is used as a logic for the test category creator, and then the normal test methods can be run through the set field in the constructor.

You can write code to read and parse the external text file in the @Parameters method (or get data from another external source), and then you can test You can add new tests by editing this file without recreating them.


1 comment:

  1. शौकिया कॉडर्स के लिए जावा नमूना कार्यक्रम
    यदि एल्स स्टेटमेंट सैंपल कोड

    ReplyDelete