-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
3 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with this change:
Reporter's log()/getOutput() is used by many reporters and would break them.
This is because the have their own handling of manipulating the strings. (It is handy to get unescaped output in some cases)
I would suggest moving this code into the *HTMLReporter.java code to allow the flexibility to pass unescaped log entries to the final reporter.
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you be more specific? I don't see any place in SuiteHTMLReporter and TestHTMLReporter that would get broken by this change.
Thanks.
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not break the internal reporters.
What I'm saying is that for example ReportNG calls Reporter.getOutput() to get the raw data and then escapes the output depending on a user specified option.
If this code is put into the log function it prevents ReportNG to offer unescaped output in their report.
The suggestion I made was to remove this code and place it inside the *HTMLReporters themselves to maintain the consistency of the log messages inside the Reporter class for others to use.
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. The problem is that every user of Reporter would have to do the escaping then, which is not optimal. I'd rather do this at the Reporter level and if users want to output a less-than or greater-than sign, they can always use the entities < and >...
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like this?
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, this looks a bit overkill for such a simple problem...
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just concerned about the impact of the committed change and put together an extendable way of achieving the same.
By helping all Reporters by escaping the special characters is also preventing all Reporters who wish to use them unescaped.
The reason the impact is so high is that replacing < with [ is impossible to revert. Where I use TestNG, this will completly wreck the implementation and will rely on writing custom code for implementation in both the loggers and reporters just to bypass this small change.
(And I won't be the only one that will have to do this)
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really, really want a "less than" character, just use the entity <, I don't see the problem...
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that would only display a < character on the screen. If I want to create a clickable hyperlink on screen, that would not really work.
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also experience problem after this change, we include links to screen shots in reporter output:
Now link does not work because "<" and ">" is changed to "[" and "]" accordingly.
Also we use ">" symbols in other places and now it is changed :(
Now my reporter log looks like this:
-----] Selenuim Server Started
=====] OH_AccountCreation: Started
Error Screenshot created for: [a href="../ScreenShots/OH_AccountCreation_Error.png"]OH_AccountCreation[/a]
[===== OH_AccountCreation: FAILED
[----- Selenuim Server Stopped
Only solution that would work for us without making major changes in our framework is to take TestNG source and build it without this change, but I believe this is not right way to go :)
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest just htmlencoding all the output, and then the client can htmlunencode it if need be. This way you prevent issues with
<
and>
and do the same thing everyone else usually does in such a case.6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as SilverFox. I am unable to include html in my report as a result of this.
<
and>
are not a feasible workaround in this regard.6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are so interested in escaping yourself, why don't you use some well known html escaper classes such as StringEscapeUtils to do StringEscapeUtils.escapeHtml4("log information link") ?
I thing that would be much safer.
after 6.7 I can't do any html tag reporting (which you came to solve) everything is treated as plain text.
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I think I'll revert the change so that the reporter doesn't do any escaping. Any client that wants escaping will have to escape the string before passing it to Reporter.log().
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: Reporter.log() doesn't do any HTML escaping by default. If you want to escape, call Reporter.setEscapeHtml(true) before you start logging.
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I encountered this problem too. When does the next version will be released ?
Thanks,
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it works in 6.8.1? It still not worked for me in 6.8.1
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using 6.8.7 and what I have figured out is that in the ./test-report/Ant Suite/*.html there is no escaping, but in the ./test-report/emailable-report.html there is escaping, that is,
in the sections generated by involking Reporter.log().
6a577ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the escaping in the emailable-report generated during Report.log() originally stems from changes here:
http://code.google.com/p/testng/issues/detail?id=91
Now in todays' codebase (I am looking at 6.8.7) I see a EmailableReporter2.java and EmailableReporter.java with some logic to choose one or the other. What is the proper way to invoke one or the other as it seems one is escaping and one is not escaping?