Tag Archives: Parameterized.class

How to parameterize test in junit with example


The custom runner Parameterized implements parameterized tests. When running a parameterized test class, instances are created for the cross-product of the test methods and the test data elements.

 how to convert array to list in java ?

package myWorkjUnit;

import java.util.Arrays;
import java.util.List;

public class ArrayToList {
 public static void main(String[] argv) {

 String sArray[] = new String []{"Array A", "Array B", "Array C"};

 //convert array to list
 List<String> lList = Arrays.asList(sArray);




package myWorkjUnit;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

/*Structure of a parameterized test class

1. A static method that generates and returns test data,
2. A single constructor that stores the test data, and
3. A test.

@RunWith(value = Parameterized.class)
public class ParameterizedTestExample {
 private int number1;

 * Constructor.
 * The JUnit test runner will instantiate this class once for every
 * element in the Collection returned by the method annotated with
 * @Parameters.

 public ParameterizedTestExample(int number) {
 this.number1 = number;

 * Test data generator.
 * This method is called the the JUnit parameterized test runner and
 * returns a Collection of Arrays. For each Array in the Collection,
 * each array element corresponds to a parameter in the constructor.
 public static Collection<Object[]> data() {

// In this example, the parameter generator returns a List of
// arrays. Each array has two elements: { datum, expected }.
// These data are hard-coded into the class, but they could be
// generated or loaded in any way you like.
 Object[][] data = new Object[][] { { 1 }, { 2 }, { 3 }, { 4 } };

 //convert array to list
 return Arrays.asList(data);

 * The test.
 * This test method is run once for each element in the Collection returned
 * by the test data generator -- that is, every time this class is
 * instantiated. Each time this class is instantiated, it will have a
 * different data set, which is available to the test method through the
 * instance's fields.
 public void pushTest() {
 System.out.println( "Parameterized Number is : " + number1);

Parameterized Number is : 1
Parameterized Number is : 2
Parameterized Number is : 3
Parameterized Number is : 4












Parameterized (JUnit API)

Link 1 Link 2 Link 3 Link 4 Link 5


For a better web


News and reviews from the world of gadgets, gear, apps and the web

Digital Inspiration

Technology, Software and Internet

Thinkwareglobal's Blog

Just another WordPress.com weblog

Kenazari's Blog

Just another WordPress.com weblog

Richfowler1's Blog

Just another WordPress.com weblog

Romaicus's Blog

Just another WordPress.com weblog


Just another WordPress.com site


Just another WordPress.com site


Just another WordPress.com site


digital media expert blog

Different Journeys

Let's make life easier!

Thinking in Silverlight

Silverlight/WPF/Windows 8 Store App




Promoting Indian language Books

Actively Lazy

Software, crafted with passion


An ongoing discussion about SAP infrastructure

SAP Career

Your Career Mentor


Just another WordPress.com site

The secret product manager

Thoughts about product management, SUSE, Linux, Arm processors, High Performance Computing, Photography, Scouts BSA, Cloud, AIX, Power Systems, and other things that interest me

Simon Les Flex's Blog

SAP Process Integration Specialist - NOW WE CAN DO BETTER!

Oracle Technologies Primer

An Oracle Fusion Middleware and iPaaS blog!

Gilberto Holms

Java, Middleware, SOA Architecture Blog

The Skeleton

Java code skeletons, tips and pointers

J@n van Zoggel

Journal of a tech junkie

The Pragmatic Integrator

Hints and tips from a pragmatic integration specialist


The pace of life..

Optimalbg's Blog

Just another WordPress.com site

IT Jobs in USA

Keep the track of this Blog if you are looking out for some good Opportunities to work in USA....

Referral Jobs | Right Place to Get a Job

Hurry you are one Click away to get a job - Fresher and High paid jobs for well Experienced IT professionals on Referal jobs.

Michael Korn's Blog

Musings on Life, Career, Faith and Technology


Just another WordPress.com weblog


.Net Core, AspNetCore, Entity Framework, Entity Framework Core, AspNetIdentity, AspNetIdentityCore, Unit Test, WCF, Workflows

Expertqtp's Weblog

Just another WordPress.com weblog

Sai Chamarthi

Experienced Testing Professional


A great WordPress.com site

Suresh4qtp's Blog

Just another WordPress.com site


This WordPress.com site is the cat’s pajamas

It's always something...

Just another WordPress.com weblog

Faculty of Information Technology - Lê Ngọc Tiến

Be Yourself! Simplify Our Goals! Nothing is Impossible!

Anti-Malware Testing

Thoughts on security product testing past and present

Methods & Tools

Practical knowledge for the software developer, tester and project manager

Mindscripts Software Testing Training Institutes In Pune

Software Testing In Pune, Software Testing Training In Pune, Software Testing Training Institute,Software Testing Training Institutes In Pune ,Software Testing Training Centers,Software Testing Classes In Pune,,Software Testing Courses Pune, Software Testing Certification In Pune,,software testing certification course in pune,software testing certification institutes in pune

edington associates

Working with organizations to develop sustainable and thriving workplaces and people.

Enterprise WordPress hosting, support, and consulting - WordPress VIP

Our best-in-class enterprise WordPress hosting platform, expert consulting and support, and diverse partner ecosystem free you to focus on your business objectives.

WORK Online

Virtual Office at HOME