I have created a maven project , with cucumber BDD and testNG . However to use testng i need to install the testng pluggin from eclipse help . The problem is my company has blocked usage of such external connections . Is there an alternative for this .
Asked
Active
Viewed 365 times
0
-
2You can create Maven project and it will download automatically, You may find Search result on that – Ishita Shah Jun 25 '18 at 14:01
-
TestNG is free source , I don't think so that they have blocked it. – cruisepandey Jun 25 '18 at 15:48
1 Answers
0
Following are your options.
- See if you can get an approval from your company's IT department to whitelist the eclipse plugin download site so that you can install it via eclipse (or) have them download the eclipse plugin jar separately, and you can drop the jar in the
dropins
folder so that eclipse is aware of it. For more information, please refer to the answers of this stackoverflow question. - If available, resort to using an alternative IDE such as IntelliJ. IntelliJ unlike eclipse, comes pre-installed with the TestNG plugin and should suffice.
- You leverage the build tool such as Maven/Ant/Gradle to run your tests from the command prompt. Both Maven and Gradle lets you run even 1 single test also at a given time. So you should be able to easily run tests without the IDE, from the command prompt (which is eventually how your tests would be run in a Continuous Integration environment such as Jenkins)
- You create a
main()
method housing class, which would use the TestNG APIs directly to create tests. So every-time you want to run a TestNG test class or a suite etc., you would merely go back to your runner class, update it with the details and then run via it [ To me this option should be your last resort]
Here's a full fledged sample for option (4), which you should be able to start tweaking for your own use.
public class Practice {
public static void main(String[] args) {
for (String each : new String[]{"A", "B"}) {
runWith(each);
}
}
private static void runWith(String group) {
TestNG testNG = new TestNG();
XmlSuite xmlSuite = new XmlSuite();
xmlSuite.setName("suite");
XmlTest xmlTest = new XmlTest(xmlSuite);
xmlTest.setName("test");
xmlTest.addIncludedGroup(group);
XmlClass clazz = new XmlClass(Practice.class);
clazz.loadClasses();
xmlTest.getClasses().add(clazz);
testNG.setXmlSuites(Collections.singletonList(xmlSuite));
System.out.println(xmlSuite.toXml());
testNG.run();
}
@Test(dataProvider = "SearchProvider", groups = "A")
public void testMethodA(String author, String searchKey) {
System.out.println("testMethodA :" + author + ", " + searchKey);
}
@Test(dataProvider = "SearchProvider", groups = "B")
public void testMethodB(String searchKey) {
System.out.println("testMethodB :" + searchKey);
}
@DataProvider(name = "SearchProvider")
public Object[][] getDataFromDataprovider(ITestContext c) {
Object[][] groupArray = null;
for (String group : c.getIncludedGroups()) {
if (group.equalsIgnoreCase("A")) {
groupArray = new Object[][]{
{"Guru99", "India"},
{"Krishna", "UK"},
{"Bhupesh", "USA"}
};
break;
} else if (group.equalsIgnoreCase("B")) {
groupArray = new Object[][]{
{"Canada"},
{"Russia"},
{"Japan"}
};
}
break;
}
//return groupArray;
return groupArray;
}
}

Krishnan Mahadevan
- 14,121
- 6
- 34
- 66