Unable to run selenium webdriver script using TestNG - eclipse

I have integrated eclipse & TestNG & could able to run one sample Java program which provides the output folder. But while included web driver script it could not run using TestNG, but able to run the same using Java program(two choices it ask while right click on the script to run).
Please le me know where the issue might be.
Thanks,
Amal

As #Chetan said in the comments - you need to attach the #Test annotation to your method.
your method would look something like...
#Test
public void myTest() {
WebDriver driver = new...
}
Also when you import, import TestNG's Test annotation. not jUnit's.

Related

Running simple Scala in Intellij

I'm trying to run a very simple hello world Scala program in IntelliJ IDEA on Mac without using the Scala console configuration. I have followed these steps to largely get started, but I didn't set up the debugger outlined there. There isn't a default run configuration enabled, but I can right-click on my source file and select "Scala Console," as we can see here:
Is there a way to select or edit my configurations to make it so I don't have to use the console? Below are the available configurations.
I simply want there to be a way to run my Scala code and see the generated output in the provided console, which Scala Console isn't doing. Thanks for your time.
Lab6 should be an object, not a class.
This will allow you to run it as a main method

Unable to execute testng in eclipse

I'm usually able to run my test with testng just fine. Now when I click "run as testng", all it does is as shown in the image below. There's no output or error message in the console.
Eclipse TestNg
The image is showing 2 tasks; happens that I clicked twice when I captured the image.
To drill down the problem, I'm just running a very simple test:
#Test
public void test(){
Assert.assertTrue(true);
}
I tried to restart PC, restart Eclipse, install fresh copy of Eclipse/testng and JDK but no luck.
Any help would be much appreciated!
the problem is related to the change i made to the host file. got it working again by removing all the losthost entries in the host file

Set openejb javaagent in code?

I'm currently writing integration tests for a Java EE application and use openejb/openjpa.
But as I'm using CMP I have to use a javaagent to enhance my classes. In maven I can configure my surefire plugin to do this enhancement, or better set the agent as vm parameter to the test.
But as I'm currently developing I like to run my tests quite often in eclipse. But there I don't want to set the agent all the time via
java -javaagent:openejb-javaagent-4.6.0.jar _\[other params...](other-params....html)
Does someone have a useful solution for this problem?
For testing in Eclipse purposes, I always create a variable that can be used in the VM arguments section of your Run Configuration. This way all you need to specify is something like ${agent} (or whatever you call it) rather than the full javaagent string.
Mhh but not sure, looking at my properties, my classes should be enhanced at runtime:
#Before
public void startupContainer() throws NamingException {
Properties p = new Properties();
p.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
p.put("openjpa.jdbc.DBDictionary", "hsql(SupportsSelectForUpdate=true)");
p.put("openejb.embedded.initialcontext.close", "destroy");
p.put("openjpa.RuntimeUnenhancedClasses", "supported");
p.put("openjpa.DynamicEnhancementAgent", "true");
p.put("javax.persistence.lock.timeout", "0");
p.put("openejb.log.factory", "slf4j");
ejbContainer = EJBContainer.createEJBContainer(p);
}

How to run individual unit tests with Zend Studio?

I noticed on Can't get Zend Studio and PHPunit to work together that a comment says
If you want ZS to run the PHPunit bootstrap, you have to specifically
select the file PHPunit.xml and tell it to run as PHPunit test. If you
just select an individual test and run as PHPunit test, the bootstrap
will not be run
That trick actually helped me to be able to run unit tests at all. However as my unit tests grow, it's becoming more and more painful to have to run the entire test suite when I just need to run my most recently written test.
So I need help adding the necessary code to the unit test (presumably in setUp) so that both the tests/bootstrap.php and the regular bootstrap for the whole application run. Hopefully this would let me do right click -> run as -> PHPUnit Test on an individual test file.
I'm new to Zend / Zend Studio so please keep answers on a basic level. The current setUp() function for one of my tests is the following, which I believe runs the whole app's boostrap:
public function setUp() {
$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
parent::setUp();
}
How does this need to change to enable running just this test file in isolation? (which I think involves calling both the tests/bootstrap.php and the application bootstrap as above)
You have to setup phpunit with zend studio / eclipse first, then you can run each unit test file individually in your IDE console.
Here's a tut that might help

Logging with SuperDevMode. System.out.println not working

Why?
When use System.out.println in client - nothing is output in console of CodeServer.
Now I'm logging in browser console, but how to log in system console?
p.s. I know that best way for logging in gwt is using com.google.gwt.logging.Logging module. It's also now working with system console.
The super dev mode is basically the same than a production compile (it just does not optimize)
In production (compiled javascript) System.out does not print anything into your java server side process. Your code runs in the Javascript VM and it would need to go over the wire to print to the java console.
If you are running in dev mode you are running inside the JVM that is connected to a plugin inside your browser. This is why System.out works.
I set up a remote logger to solve this problem. This way all the client log statements are sent to the server where the logging still works. You can find instructions here: Setup a remoteLoggingServlet in GWT.
Then you can use normal java util logging.
import java.util.logging.Logger;
private static Logger log = Logger.getLogger("mylogger");
Stack traces are unfortunately in javascript. I haven't figured out how to get proper java ones yet.
Hope this helps!
Not the prettiest of solutions but you can create a native JSNI method like this:
public static native void debug(String text)/*-{
console.debug(text)
}-*/;
Then just call:
debug("text here").
And it should output to the console.