i followed the steps that are given for cobertura report and i generated report with following steps given in the URL Cobertura on Tomcat
but now my problem is to generate cobertura report without stopping tomcat
There are only 2 Ways to create a coverage data file.
Stop Tomcat
Execute a piece of code, that tells cobertura to write the file
Regarding the Second approach: You have to call this function yourself, after your tests run. You could (for example) put this code in a servlet (which you call at the end of your tests).
If you don't stop Tomcat or execute the function, you will not get a coverage data file.
This is from the cobertura FAQ
Cobertura only writes the coverage data file when the application server shuts down. We do not want to stop our application server after running our tests.
It is possible to instruct Cobertura to write the data file. One of
your classes should call the static method
net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData().
For example, you could add something like this to a "logout" method in
your web application:
try {
String className = "net.sourceforge.cobertura.coveragedata.ProjectData";
String methodName = "saveGlobalProjectData";
Class saveClass = Class.forName(className);
java.lang.reflect.Method saveMethod = saveClass.getDeclaredMethod(methodName, new Class[0]);
saveMethod.invoke(null,new Object[0]);
} catch (Throwable t) {}
Related
I am currently in the process, with a Jmeter script, of opening firefox browsers which are functional. However, I have a small problem which is to let the browsers turn on even after the script is finished.
Currently my browsers turn off once the script is finished.
Here is my code :
WDS.sampleResult.sampleStart()
def display = WDS.vars.get("DISPLAY");
WDS.browser.get('url'+ display +'set')
WDS.sampleResult.sampleEnd()
Is there a possibility to do it?
Are there additional parameters to set in the webdriver sampler, because I don't have an HTTP Sampler or even HTTP cookies.
Thank you for your time
I think if you tick Development Mode box the browser will remain open:
If it doesn't fit your needs, i.e. you're using headless or Remote WebDriver, looking in the source code
#Override
public void threadFinished() {
if (!isDevMode()) {
final T browser = removeThreadBrowser();
quitBrowser(browser);
}
}
so just comment out/remove this quitBrowser function, recompile the plugin and replace the version in the "lib/ext" folder with your own one.
and last but not the least the browser is being shut down when your test ends, if you want to keep the browser open it's sufficient to configure your test so it would never end by adding i.e. Flow Control Action sampler configured to sleep the required amount of time or just adding the next line as the last one in your WebDriver Sampler code:
Thread.sleep(3600000)
the line will pause the execution for 1 hour, hopefully this time will be sufficient for troubleshooting.
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?
Problem
It is not clear to me how to configure the Kotlin MPP (multiplatform platform project) using Gradle (Kotlin DSL) to use Vert.x web for Kotlin/JVM target with Kotlin React on the Kotlin/JS target.
Update
You can check out updated minimal example for a working solution
inspired by an approach of Alexey Soshin.
What I've tried
Have a look at my minimal example on GitHub of a Kotlin MPP with the Vert.x web server on the JVM target and Kotlin React on the JS target.
You can make it work if you:
First run Gradle task browserDevelopentRun (I don't understand magick behind it) and after browser opens and renders React SPA (single page application) you can
stop that task and then
start the Vert.x backend with task run.
After that, without refreshing the remaining SPA in the browser, you can confirm that it can communicate with the backend by pressing the button and it will alert received data.
Question
What are the possible ways/approaches to glue these two targets so when I run my application: JS target is assembled and served via JVM backend conveniently?
I am thinking that perhaps Gradle should trigger some of the Kotlin browser tasks and then make them available in some way for the Vert.x backend.
If you'd like to run a single task, though, you need that your server task would depend on your JS compile. In your build.gradle add the following:
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
dependsOn(tasks.getByName<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack>("jsBrowserProductionWebpack"))
}
Now invoking run will also invoke WebPack.
Next you want to serve your files. There are different ways of doing it. One is to copy them to Vert.x resources directory using Gradle. Another is to point Vert.x to where WebPack puts them by default:
route().handler(StaticHandler.create("../../../distributions"))
There is a bunch of different things going on there.
First, both your Vert.x and Webpack run on the same port. Easiest way to fix that is to start Vert.x on some other port, like 18080:
.listen(18080, "localhost") { result ->
And then change your index.kt file to use that port:
val result: SomeData = get("http://localhost:18080/data")
Because we run on different ports now, we also need to specify CORS handler:
router.apply {
route().handler(CorsHandler.create("*"))
Last is the fact, that you cannot run two neverending Gradle tasks from the same process (ok, you can, but that's complicated). So what I suggest is that you open two Terminals, and run:
./gradlew run
In one, and
./gradlew jsBrowserDevelopmentRun
In another.
Having done all that, you should see this:
Now, this is for development mode. For production mode, you probably don't want to run jsBrowserDevelopmentRun, but tie jsBrowserProductionWebpack to your run and server spa.js from your Vert.x app using StaticHandler. But this answer is already too long.
I want to run a ftp listener class only when the server starts and not when console, generators, dbconsole, test, destroy, runner and rake commands run.
I've found some people doing same thing with rails 3 and 4 using checks like defined? Rails::Generators but I can't get it working in rails 5, I do not get any return with the defined check.
The config.ru file is only used by web servers and not loaded by the console script, rake tasks or even your test suite. What you put there is only executed when a server instance launches.
Web servers themselves have also ways to do this. When you use Puma for instance, there are hooks like on_worker_boot or after_worker_boot, which may come to help (http://www.rubydoc.info/github/puma/puma/Puma/Configuration/DSL).
However, I'd recommend integrating this into your deployed server environment and out of the Rails app.
I created Spring Boot + Google App Engine application. For development purpose I use IntelliJ IDEA and Google Cloud Tools plugin. I'm currently using only localDebug, which means I don't deploy anything on Google cloud. The configuration for debug is below:
I created a simple service to be sure if my code is updated on change or not:
static int i = 10;
#GetMapping(value = "/test")
public String test() {
return Integer.toString(++i);
}
Unfortunately when I change my code (e.g. from i = 10 to i = 100) and restart the app (I mean press on Rerun (Ctrl+F5) or Stop (Ctrl+F2) + Run my code doesn't apply on server, which means Idea doesn't rebuild the sources on server start. As you see on the screenshot above I even tried to add Build Project step to Before launch, which didn't work.
So to apply changes I need to execute from command line mvn appengine:run -> press Ctrl+C to stop it, switch to IDEA and start debug again which is a pain in the ass.
Another option is to use Hot Reload (Update application, Ctrl+F10). It recompiles only changed classes and reloads resources. This is a cool feature, but unfortunately it doesn't work in a lot of cases which makes me unable to use it as a reliable reload.
Is there anything I can do to force IDEA compile my sources? Is it a bug I should report to plugin developer. Or maybe appengine uses some additional remote sources that require explicit call of maven?
I finally found a solution. As I understood the Google cloud plugin just complies the classes into target/classes but when it starts the appEngine, the engine expected unpacked .war to be present under target/demo-0.0.1-SNAPSHOT.
E.g. if because if I delete both directories I get the error below:
To solve the issue I needed to compile those sources:
In toolbar Run -> Edit configuration
Select Google App Engine Standard Local server
In before launch add Build Artifact -> demo:war exploded where demo is the name of your App.
I am Using GAE and java with JDO . I have the server side code and would like to run it from command prompt, rather than initiating from a browser (as its tedious to debug server side code by running the browser every time), but how do I do that ?, what would be the starting point (start a PersistenceManager, request thru port 8888 ) ?. I am looking for some guidance.
Following is my server side code, optimize is the method i would like to call from command line, where it needs to get data from the local app engine
#SuppressWarnings("serial")
public class OptimizerServiceImpl extends RemoteServiceServlet implements
OptimizerService {
public static void main(String args[])
{
System.out.println("comes in: ");
optimize();
}
public String optimize(ModelRunDTO moDto)
{
PersistenceManager pm = PMF.get().getPersistenceManager();
Data data = pm.getData(); // gets the data thru pm
// all my logic goes here......
}
Thanks alot.
To supplement Peter's answer above, if you're just trying to test and debug your code, you may want to use a unit test. This document explains local unit testing for Java App Engine. In particular, you'll be interested in writing datastore tests, which uses an in-memory implementation of the datastore (and flushes the contents between tests). Because these tests are based on JUnit, you can run them from the command line, or through the IDE of your choice.
The only way to invoke anything on GAE is via a HTTP request. You can make HTTP requets from command line (OS-specific), for example
wget http://yourapp.appspot.com/path