Аннотация @Parameters также служит для параметризации тестов. Пример для работы с БД:

@Test
	@Parameters({"driver", "url", "username", "password"})
	public void connectToH2 (String driver, String url, String userName, String password) throws Exception {
		Class.forName(driver).newInstance();
		Connection conn = DriverManager.getConnection(
				url, userName, password);

		Statement st = conn.createStatement();
		st.execute("DROP TABLE STUDENTS IF EXISTS");
		st.execute("CREATE TABLE STUDENTS(ID INT PRIMARY KEY, NAME VARCHAR(255),  HOBBY VARCHAR(255));");
		st.execute("INSERT INTO STUDENTS VALUES(1, 'Ivanov', '')");
		st.execute("INSERT INTO STUDENTS VALUES(2, 'Petrov', 'Swim');");
		st.execute("INSERT INTO STUDENTS VALUES(3, 'Sidorov', '')");
		st.execute("INSERT INTO STUDENTS VALUES(4, 'Andreev', 'Wrestling');");
		ResultSet result = st.executeQuery("SELECT * FROM STUDENTS");
		String ID = "", NAME = "", HOBBY = "";

		while (result.next()) {
			HOBBY = result.getString("HOBBY");
			ID = result.getString("ID");
			NAME = result.getString("NAME");
			if (HOBBY.equals("")) {
				HOBBY = "Нет хобби";
			}
			System.out.printf("%3s | %-10s | %-10s \n", ID, NAME, HOBBY);
		}
	}

XML для работы с параметрами выглядит так:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
	<test name="Test">
	<parameter name="driver" value="org.h2.Driver"/> 	
	<parameter name="url" value="jdbc:h2:tcp://localhost/~/test"/> 	
	<parameter name="username" value="sa"/> 	
	<parameter name="password" value=""/> 	
		<classes>
			<class name="p1.TestNgClass" >
				
			</class>
		</classes>
	</test> <!-- Test -->
</suite> <!-- Suite -->

В XML мы задаем параметры, т.е. driver =
org.h2.Driver, url = jdbc:h2:tcp://localhost/~/test и т.п.
Эти параметры передаются в тестовый метод.

Реклама