dimanche 6 janvier 2019

How does GebSpec hide the field _browser and what is $spock_sharedField__browser good for?

I try to understand more about how Geb and Spock work internally to understand what is really happening in my tests. I found that GebSpec which I extend to write my tests has a field Browser _browser. I also found that GebSpec has a method getBrowser() which returns _browser, so _browser can be accessed over getBrowser() and get_browser(). But the interesting part is that while debugging in intelliJ expanding an instance of GebSpec shows no field _browser but only a field $spock_sharedField__browser. A little example:

Debugging my Class: The instance of GebSpec has a field spock_sharedField__browser but no field _browser

How do they manage to hide the _browser field from me in the debugger and why do they do it? Recall a field Browser _browser is declared in GebSpec and a field $spock_sharedField__browser is not. There also is no method get$spock_sharedField__browser() but i still can access and manipulate $spock_sharedField__browser. I tried to do it myself:

I wrote a class TestClass that declares _browser exactly analog to GebSpec, but if I debug here the field _browser is shown normally as one would expect

Can someone explain me what is going on? Why hide _browser? What is $spock_sharedField__browser good for?

Aucun commentaire:

Enregistrer un commentaire