03
Sep

Beanshell based TestNG Execution

Beanshell based TestNG Execution
==================================

#1. pom.xml dependency:
========================

<dependency>
    <groupId>org.beanshell</groupId>
    <artifactId>bsh</artifactId>
    <version>2.0b5</version>
</dependency>


#2. pom.xml for Beanshell script:
==================================

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
	<test thread-count="5" name="Test">
		<method-selectors>
			<method-selector>
				<script language="beanshell">
                <![CDATA[packageName = System.getProperty("packageName");
                method.getDeclaringClass().getPackage().getName().contains(packageName);]]>
				</script>
			</method-selector>
		</method-selectors>
		<classes>
			<class name="testNG.Beanshell.Processing.ActualTestNGTests" />
		</classes>
	</test>
</suite>



#3. Execute your TestNG methods with testng.xml by Passing VM Arguments as:

-DpackageName="testNG.Beanshell.Processing"