Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener: add text to error text? #2258

Closed
MCMic opened this issue Aug 2, 2016 · 6 comments
Closed

Listener: add text to error text? #2258

MCMic opened this issue Aug 2, 2016 · 6 comments

Comments

@MCMic
Copy link

MCMic commented Aug 2, 2016

Hello,

I wanted to create a modified version of PHPUnit_Extensions_Selenium2TestCase_ScreenshotListener to add a link to the screenshot in the error text.
But I can’t find any way to alter output using a Listener, it seems printf just outputs to the terminal, and I’m not sure if a listeners methods can return something and how it should be formatted?
How can a Listener add some text to the test result?

@sebastianbergmann
Copy link
Owner

Listeners are for listening. They should not modify anything.

@MCMic
Copy link
Author

MCMic commented Feb 7, 2017

Then how can I add a link to the screenshot in the error text?

@sebastianbergmann
Copy link
Owner

I do not know anything about PHPUnit_Extensions_Selenium2TestCase_ScreenshotListener so I cannot help you. Please bring this up with the vendor of your PHPUnit extension.

@MCMic
Copy link
Author

MCMic commented Feb 7, 2017

This is a more general question about how to add information to tests results.
This listener create a screenshot on failure which is quite useful but I have to search for which file match which failed test myself. It would be useful if I could expand the failed test text so that it contains the filename (which is generated from easily available information like test name and such things).

@sebastianbergmann
Copy link
Owner

A listener is a listener. It must only listen. If it does something more then that is wrong.

It is a mistake in the implementation of PHPUnit that listeners can manipulate PHPUnit\Framework\Test object. I should have fixed this mistake a long time ago. I plan to correct this for PHPUnit 7 (see #2477).

@MCMic
Copy link
Author

MCMic commented Feb 7, 2017

You already said this, my question is what can I do to alter the test result text. I won’t use a Listener if it can’t do it, is there an other way mechanism capable of altering the text output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants