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

Remove use of TestListener #432

Open
joesaunderson opened this issue Jul 3, 2019 · 19 comments
Open

Remove use of TestListener #432

joesaunderson opened this issue Jul 3, 2019 · 19 comments

Comments

@joesaunderson
Copy link
Contributor

In PHPUnit 8, TestListener and TestListenerDefaultImplenentation are deprecated.

This is preventing PHPUnit_Selenium from supporting PHPUnit 8.*

@joesaunderson
Copy link
Contributor Author

@thewunder - I will try and pick this up soon to get a 8.* release out too

@luckydonald
Copy link

Is this just used in PHPUnit_Extensions_Selenium2TestCase_ScreenshotListener?

@luckydonald
Copy link

luckydonald commented Jul 3, 2019

According to sebastianbergmann/phpunit#3388, "Use the TestHook interfaces instead".
More here: sebastianbergmann/phpunit#3390

@joesaunderson
Copy link
Contributor Author

This does not seem as simple as first thought, the hooks pass through the name of the Test, not the Test class itself, so calling $test->currentScreenshot() is not possible.

Any suggestions?

@luckydonald
Copy link

How was the ScreenshotListener used before? Maybe we can do it differently?

@luckydonald
Copy link

So, Session::currentScreenshot() calls what is appearntly a raw selenium command?

@luckydonald
Copy link

luckydonald commented Jul 3, 2019

Not being able to access the test seems to be a feature.

Maybe we need to take a step back here.

So what is the use case of that?
As far as I can gather

  • a) Providing a helper method for writing a png file to disk
  • b) Hooking into the system, to make a screenshot of the test on failure/error.

So.
a) could be easily refactored out of there to be simply a helper.
b) needs a bit more thinking.

@luckydonald
Copy link

luckydonald commented Jul 3, 2019

b)

Maybe we need something like (please excuse the pseudo code)

class ScreenShotOnErrorListener() implements TestHookOrSomething { 
   function construct($test) {
      $test->attachListener($this);
      $this->test = $test;
   } 

   function onFailure(string $test_name_whatever) {
        $this->test->currentScreenshot();
   } 
 }

class SomeTest {
   function onSetup() {
       new ScreenShotOnErrorListener($this);
   }
}

@luckydonald
Copy link

b) makes me feel this is a design flaw that we can only access the selenium API from the $this test class.

@luckydonald
Copy link

luckydonald commented Jul 3, 2019

To have asked the question:

Is the ScreenshotListener a feature we need to keep?

@luckydonald
Copy link

@joesaunderson How would that be used?

@joesaunderson
Copy link
Contributor Author

Scratch that, it wouldn’t work at all.

Struggling to work out how the existing listener can be used in the same way.

What are your ideas @thewunder?

@luckydonald
Copy link

luckydonald commented Jul 17, 2019

Note, until we have that fixed, using the fork where I removed the version limitation works as long as this class discussed here isn't used.

@joesaunderson
Copy link
Contributor Author

Does anyone have further ideas of how we can remove the use of the TestListener

@luckydonald
Copy link

When bumping version from 4.x to 7.x that's an incompatible change, so we could just remove it?
So far I have not seen an actual use case.

@SteveDesmond-ca
Copy link

+1 for just removing it so we can get a PHPUnit 8 compatible version out the door. Worst case scenario, something similar can be added in an 8.x release.

My use case for screenshots: when a browser test fails (onNotSuccessfulTest()), take a screenshot of the entire page to show the current state at the point of failure, for debugging assistance. This still works fine, as it's happening within a Selenium2TestCase.

@pajon
Copy link
Collaborator

pajon commented Jan 22, 2020

Hi guys,

there are already merged PR (#441, #443), we can release 8.0 version. It is only deprecated and all tests are passed, its fine for now.

We must probably fix this until we approach to PHPUnit 9.* (will be released in February 2020)

Is there any solution how to dont remove this feature ?

@thewunder
Copy link
Collaborator

I don't see a way to keep this feature, and I'm OK with removing it. @pajon and I discussed wanting to get w3c mode working before we release 8.0

dev-master is compatible with 8.0 if you are feeling adventuresome.

@pajon
Copy link
Collaborator

pajon commented Feb 3, 2020

@thewunder

i tried compatibility with w3c, but it will need a huge amount of time and refactor whole library. php-webdriver w3c talk.

If we want ensure backwards compatibility with current JsonWire protocol, we must add way to choose between webdriver protocols.

For me is better release 8.0 version from master and add compatibility in future release (maybe 9.0)

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

5 participants