I heard that ReportNG creates a better report than TestNG's normal report. I tried to create ReportNG report, but failed. I am using Eclipse and I have downloaded ReportNG and added reportng-1.1.3.jar and velocity-dep-1.4.jar into classpath and written testng-suite.xml as below:
<suite name="SA" verbose="10">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
...
</suite>
when I executed I could see the TestNG default report rather than ReportNG report. What else should I do to get ReportNG's report (like extend any class or implement listeners or write snippet of code)?
Also I heard that I have to use the command, useDefaultListeners="false" , but where should I include in the testng-suite.xml? Everyone is telling about ANT but I don't personally like it to use. So is there any way to include the above command into testng-suite.xml?
I am the author of ReportNG. You don't need to write any Java code to get it to work. You just need to be able to register listeners with TestNG from whichever tool you use.
I've only used ReportNG from Ant but other people have got it working with other build systems such as Maven and Gradle. I don't know if there is anything Selenium-specific that would prevent it from working. Are you getting any error messages? The first thing I would check is to make sure that the ReportNG JAR is on the classpath.
I didn't even realise that you could specify TestNG listeners in the testng.xml file. However, I have just modified my sample reports to specify the listeners in this way rather than in the Ant build file and it works fine, so the problem is probably in the way you are configuring TestNG from Selenium.
How are you launching from Eclipse? You should be right-clicking on that XML file and select "Run as... TestNG suite". I'm assuming that's what you're doing.
Using default listeners should not have any impact on the problem you are seeing, I am guessing that some people use this because if they use ReportNG, they don't care about any of the other listeners that TestNG generates. Having said that, if you ever want to do this from Eclipse, you can simply edit the launch configuration that was created when you launched your suite as indicated above and add "-usedefaultlisteners false" to the parameters box.
To disable defaultlisteners ,
Goto Eclipse Project-> Properties -> TestNG -> Disable deafult listeners.
After running you will end up with following error:
java.lang.NoClassDefFoundError: com/google/inject/Module
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
to solve this, download google-guice-3.0.zip and paste guice-3.0.jar into your classpath.
Now run and check the report in workspace/test-output/html.
Related
I have created a custom TestEngine using the JUnit 5 (junit-platform-engine) framework.
The custom TestEngine registers using the ServiceLoader mechanism with an entry in META-INF/services/org.junit.platform.engine.TestEngine.
When I run my tests, this works well, but the tests get run a second time by the built-in JUnitTestEngine.
Is it possible to replace the default TestEngine in this circumstance instead of supplement it?
After checking the JUnit 5 user guide and documentation for maven surefire plugin it seems there's currently no way to filter out certain test engine with Maven :-(.
Using the console launcher, however, does allow to choose test engines: https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher-options. And so does Gradle: https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle.
I am trying to setup a test project that uses serenity and jbehave
I am noticing that all examples use serenity.properties that define a browser in it
I would like to structure my tests in a way so that same test can be executed in IE/firefox/chrome etc
How do I do this?
You can pass in properties as command line properties, so you can rerun the same tests with different browsers by passing in different settings for webdriver.driver, e.g.
$ mvn verify -Dwebdriver.driver=firefox
$ mvn verify -Dwebdriver.driver=chrome
etc.
I think you are able to get this to work by creating multiple Junit test classes with each its own driver and execute them all in a single run.
Every test class should be able to assign a specific 'managed' driver (e.g. PhantomJS, Chrome, Firefox). This is documented here: http://www.thucydides.info/docs/serenity/#_serenity_webdriver_support_in_junit
I don't know what the impact this would have on the generated report, hopefully you are still able to identify the feature/driver combination.
I am fairly new to Griffon and have some experience with Grails.
I have a problem loading a file from the resources directory.
I am using Griffon version 1.4.0.
When I run griffon run-app the following code (inside a Service) to get the location of an XML file works fine:
URL resource = getResourceAsURL('schema.xsd')
assert resource != null : "schema cannot be located"
When I run griffon test-app however the same code produces an assertion error because the returned URL is null. Same behaviour with getResourceAsStream().
This happens in the unit test of said service.
I put the file in ./griffon-app/resources.
What am I doing wrong? Do I have to copy all resources from production to some test resources folder, do I have to edit the build-configuration?
Thanks in advance!
Edit as suggested below I filed a bug report in the griffon-projects issue tracker.
araxn1d is correct, running the tests in integration mode will give you the right answer because the full application gets bootstrapped before tests are run. Now, running this kind of test (a unit test that depends on resources being available in the classpath) encounters a problem because the classpath is not setup correctly. Executing the following command
griffon -Dgriffon.cli.verbose=true test-app --unit --compileTrace=true
will output all classpaths. There you can see that the resources directory points to $USER_HOME/.griffon/1.4.0/projects/<project_name>/resources. If you inspect that directory you'll find the file you're looking for inside griffon-app/resources. This means the test classpath is not accurately configured as it should be $USER_HOME/.griffon/1.4.0/projects/<project_name>/resources/griffon-app/resources instead. This is clearly a bug, most likely found in the $GRIFFON_HOME/scripts/_GriffonClasspath.groovy script. Could you please file a JIRA http://jira.codehaus.org/browse/griffon ticket for it? Thanks!
You should run test-app to run your unit tests. In this case you should mock any refers to real files, otherwise you should implement Integration Tests. Pls see Griffon Testing. Integration tests differ from unit tests in that you have full access to the Griffon application within the test.
i started hub with ant ,i dont to start rc using ant instead
i want to invoke it from code .iam using junit to run rc .please
suggest me how??
If you really must do this, take a look at the build.xml file. The "launch-remote-control" task should give you all the information you need. You can see the Java class being invoked as well as the arguments being passed through. You'll need to make sure you have everything in the vendor/ directory on your classpath, too.
I'm aware of how to start a java progam with a java agent:
java -javaagent:myAgent.jar MyJavaProgram
But what if I want to add 2 or more java agents to instrument my program? I do not want to reinvoke the java -javaagent:... for every agent I have to load in JVM.
I've tried something like this :
java -javaagent:agentA.jar, agentB.jar MyJavaProgram
or something like this:
java -javaagent:agentA.jar agentB.jar MyJavaProgram
But have no success.
Is there an answer to solve my problem ?
Thank you.
How about two javaagent parameters?
java -javaagent:agentA.jar -javaagent:agentB.jar MyJavaProgram
It would appear you can do this by using multiple arguments. From the documentation:
On implementations with a command-line interface, an agent is started by adding this option to the command-line:
-javaagent:jarpath[=options]
jarpath is the path to the agent JAR file. options is the agent options. This switch may be used multiple times on the same command-line, thus creating multiple agents. More than one agent may use the same jarpath. An agent JAR file must conform to the JAR file specification.
(my emphasis)
Adding to the above answers, if you are using ant and want to include <jvmargs /> with more than one jar to -javaagent to start the server, here's how I did it,
build.xml
<target name="blah">
...
<jvmarg value="-javaagent:${jar1.path}" />
<jvmarg value="-javaagent:${jar2.path}" />
...
</target>
There is a new project with the goal to support multiple Java agents. Currently it is limited to specific ones.
Agent Bond is a super agent, which wraps and dispatches on several other agents. That way, you only have to install a single agent within your JVM with a single set of configuration data (which contains multiple separate parts).
See https://github.com/fabric8io/agent-bond/blob/master/README.md for details