Cucumber runtime exception when my feature file contains Korean characters - java

I have looked everywhere on the web to see if anyone posted a similar issue but not been so lucky. I am running automation tests scripts using Java with Cucumber JVM. I have a step that involves verifying a Korean character but when I try to run it, i get a cucumber.runtime.CucumberException: Error parsing feature file
Does anyone have a suggestion about this? It's imperative i use that character as part of my input as it's verifying a site based in Korea.
Hope that is clear enough.
Thanks in advance

You need to add # language: ko in your feature file (the very first line)

Related

Can I run the SonarQube Java Analyzer without running the scanner? And how?

I want to get the syntax and semantic info for a given Java file, and it seems that I have to run the SonarQube scanner to get such data. However, I don't want to do this, because I have to create a new project and the results will be displayed on the web page. So is there a way to run the Java analyzer immediately and provide relevant syntax and semantic data for a Java file?
Thanks a lot~
You can use plugins like sonarlint,which will show the issues for opened file on IDE itself.

How to tell what library logged an Error

I'm getting the following in my console. It's not coming from my code. I've placed several libraries such as WebLogic, sun, javax, in my step filters. Is there a way to tell which library generated this message? I don't really want to step through all of the library classes that I'm using to try to find this.
[Fatal Error] :1:80: The element type "body" must be terminated by the matching end-tag "</body>".
When this happens to me, I typically first reach for Google. These days most error messages have been posted by someone somewhere, although you have to ensure you strip your specifics (in this case the "body" sounds pretty specific) out of it.
If Google doesn't help or just takes too long, I typically end up running a binary search tool over my lib directory. The results aren't pretty. But once I know which jar contains the message, I can zoom into a prettier format for the details.

Character encoding issues in Eclipse for Java using Webdriver

I'm currently using Eclipse with TestNG running selenium webdriver with java. I am using Jexcelapi to import data from OpenOffice (spreadsheet) to compare strings on the website i'm testing with values in the spreadsheet. The problem I have is that we have different regions including germany and Nordics (Sweden, Norway and Denmark). These sites have string characters with accents special characters. This is copied correctly on my spreadsheet and running the scripts in debug mode shows the correct character from the spreadsheet but when i get my results, it displays invalid characters such as ? and whitespace. I have looked through the forum and searched everywhere for the past few days and seen various solutions but none seemed to work. I'm not sure if the problem is with Eclipse, Jexcelapi or OpenOffice.
I changed the encoding settings in Eclipse to UTF-8 as advised in some places but still the same problem. I instantiated the class 'WorkbookSettings' and set the encoding and used it with my getWorkbook method and I still get those bad characters that make my scripts show failures.
Can anyone help with this please?
Thanks in advance
We had a similar problem when running webdriver on a remote machine and trying to paste text into forms. The tests were working on our development machines.
The solution was setting the environment variable
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF8
After that the webdriver copied with the right encoding for swedish characters.

Accessibility of test coverage reports for blind people

I am currently helping a member of my team to get in grip with our new project and the tools we are using. We use Java as a primary language. A particularity of my colleague is that he is blind. He's working primarily with Emacs, and he runs maven targets in a terminal.
After I'm done implementing, I find it very useful to check my test coverage. I'd like my colleague to be able to check coverage as well. I have two ways of getting this information:
Use IntelliJ integrated test coverage (it uses EMMA and shows a green, red or yellow color next to each line). Very convenient, as I can see this information immediatly after having run the tests, with no further interaction
This won't work for my colleague as he can't use IntelliJ, and it would probably not work anyway as there is no textual representation of the coverage info
Use Cobertura reports. They use the same concept of line in green/red They are fine for macro information like overall coverage in a class, but not for checking which line has not been covered.
Actually he could dig into the HTML sources of the report and find out which one has class nbHitsUncovered, but it seems very impractical.
I would really like to show him how to get his coverage data quickly. Does anybody know of a tool that shows coverage without relying on colors? Or do we have to write our own? (by transforming the HTML report, for instance)
I’m a totally blind developer who does my work on Windows with the Jaws for Windows screen reader so this won’t map exactly to the developer you work with. With a little programming it looks like cobertura test results are the easiest to deal with. Based on the following sample XML report it shouldn’t be difficult to throw together a quick Perl script to check for lines with a hit count of 0.
https://raw.github.com/jenkinsci/cobertura-plugin/master/src/test/resources/hudson/plugins/cobertura/coverage-with-data.xml
I was able to find out that line 24 was the only one executed 0 times with a quick find for
Hits="0"
Although I was able to find out what line wasn’t executed I had to scroll up quite a bit to figure out what class and method the line was located in. A quick Perl script could eliminate the need to scroll back and provide the package, class, and method the line is located in more efficiently.
I took a look at a sample Emma HTML report using Google Chrome and it was pretty accessible. I could tell what methods were fully tested and what weren’t. Figuring out what lines were executed and what ones weren’t was more difficult. I could tell a method wasn’t 100% executed and would then navigate to it in the report. I then had to use the keystroke provided by my screen reader to announce color on each line of code. I forget the exact color names but I could tell the lines that were and weren’t executed since my screen reader listed them as having different colors. This worked but was slow since I had to manually check each line of a method; that wasn’t completely executed since my screen reader can’t automatically announce color changes. I’m not sure how your developer would do the equivalent since I don’t know his exact assistive technology setup.
I have had a dig around Antoine as I also use SONAR and Cobertura on my projects and am intrigued by your problem. From what I can see when you tell the ANT task to generate "html" as the output you get all the line information that want, but as you've pointed out it's not an easily parseable format (and possibly subject to change).
With SONAR I tell Cobertura to output "xml" which gives me a file named coverage.xml with the output. Unfortunately it does not include line-by-line data and I cannot see any ANT task parameters to include it from the Cobertura docs.
It makes sense to me that the file named cobertura.ser contains all of the data you require, but only the HTML report displays it for you. I believe the answer to your question may lie in trying to extract the required serialised data from cobertura.ser.
Looking at the source code I can see the following classes
net.sourceforge.cobertura.reporting.html.HTMLReport
net.sourceforge.cobertura.reporting.xml.XMLReport
What I suspect you can try and do is take a copy of the HTMLReport as a base and try writing the same output as XML which you can then parse for your own purposes (or mjust ad the same method calls used by HTMLReport in XMLReport). I can see the string nbHitsUncovered in HTMLReport so hopefully you only have one class to write.
I've googled around and can't see anyone having done this, but it looks like a useful enhancement.
How about using a GreaseMonkey script that searches all the lines having the class nbHitsUncovered and adds some list/table containing the information wanted to the report?

Java debugging - Searching for a string in the package in a jar

I am debugging a Java package and I need to search for some debug statements being spitted out in the cmd to find out where in the code the program got stuck at. What type of search programs would you use to search for a debug message being printed onto screen in a large Java package? I tried using the ordinary Windows search using the "A word or phrase in the file" but I don't think it is doing it's job. Any recommendations?
Thanks.
To search for a string within a JAR (and include meaningful context) you can use the search (not find, which only works with a single class) function in Java Decompiler. How useful its output is will depend on whether the JAR has been run through an obfuscation tool.
In Eclipse, you can search your entire project or packages with Search -> File
but you should reconsider your debugging techniques, since there are better Methods than Printing to the CMD

Categories