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

hiding "technical" tests in report #471

Closed
adrian-herscu opened this issue Jun 17, 2020 · 15 comments
Closed

hiding "technical" tests in report #471

adrian-herscu opened this issue Jun 17, 2020 · 15 comments

Comments

@adrian-herscu
Copy link

Sometimes there are tests which exist only to initiate some state but they are not the focus.

For example, logging-in is required by all scenarios in an application and there also might be a dedicated LoginTest class, however the login itself is just some technicality for most scenario methods and we would like to keep it hidden in the test report.

Sometimes this can be solved with @before... stuff, but sometimes it requires too much tricks and doing it in a separate test method upon which others depend is much simpler.

Can it be done with current library? Any direction about where I need to look in order to implement such thing myself?

@janschaefer
Copy link
Contributor

One way would be to just use standard mechanism of JUnit for this.

@adrian-herscu
Copy link
Author

Hmmm... I do not use JUnit :(
What is the standard mechanism for this in TestNG?

@janschaefer
Copy link
Contributor

What I basically meant was that you can execute test code outside of JGiven. That way it will also not appear in the report. In TestNG this could be done with a method annoted with @BeforeTest.

@adrian-herscu
Copy link
Author

Yes I know that the @Before/@after methods are not reported.
Still there are situations, for example when testing long scenarios on Web/mobile applications, due to performance reasons, these have to be done inside same @Before/@after context but spread across multiple test methods. We have many of these:

class JumbleBumbleMobileTests {
  @BeforeClass
  public void beforeClassStartMobileApplication() {...}
  @AfterClass
  public void afterClassQuitMobileApplication() {...}

  @Test
  public void shouldLogin() {...}

  @Test(dependensOnMethod="shouldLogin")
  public void shouldAssociatePerson() {...}

  // This is the important method -- the ones before are just kind of initialization;
  // also these previous initialization methods are repeated in every test class
  @Test(dependensOnMethod="shouldAssociatePerson", dataProvider="details")
  public void shouldHaveDetails() {...}
}

@l-1squared
Copy link
Collaborator

@adrian-herscu wouldn't it be possible to just define these technical tests as a JGiven test step and then make use of the @Hidden annotation?

@adrian-herscu
Copy link
Author

@adrian-herscu wouldn't it be possible to just define these technical tests as a JGiven test step and then make use of the @Hidden annotation?

For simple cases that is the correct approach.
Now consider having an initialization that comprise of:

  1. launching a mobile application
  2. login
  3. sending a REST request
  4. verifying something was logged in Logstash
  5. setting up something in the application

These are 3 different interfaces to juggle between including actions and verifications.
So far I managed to keep actions and verifications in separate classes. Also I keep separated sets of classes for mobile, REST, SSH, and other interfaces. Doing all the above in a step means mixing all these.

@adrian-herscu
Copy link
Author

I am thinking about changing the current JGiven reporting mechanism to recognize @hidden annotation on test methods to and just ignore these for reporting purposes.

@l-1squared
Copy link
Collaborator

l-1squared commented Jun 19, 2020

@adrian-herscu might not be the worst idea. In a sense. Having @hidden work for tests and stages is more intuitive than having it only work for one of them

@l-1squared
Copy link
Collaborator

Hi,
@adrian-herscu I haven't heard from you about this issue in a while. Did you resolve your issues, so that this ticket can be closed?

@adrian-herscu
Copy link
Author

Hi,
@adrian-herscu I haven't heard from you about this issue in a while. Did you resolve your issues, so that this ticket can be closed?

I started to look into ScenarioExecutor but found it too complex to override its behavior...
If I am not wrong, that is the place where the reporting is done. So if I will be able to hook into my handler then I will be able to filter out test methods based on some criteria, e.g. having some annotation. Any suggestion about how achieve that without rewriting the entire class or using some intrusive methods like AspectJ?

@l-1squared
Copy link
Collaborator

I will take a look into it this week and hopefully come up with a suggestion for you

@l-1squared
Copy link
Collaborator

l-1squared commented Jul 13, 2020

Hi @adrian-herscu,
I finally had got to look into the code. It seems you are right. In hide tests via an annotation, one would have to add changes in ScenarioExecutor , ScenarioModelBuilder and others.

However, I just tried to run a test within a JGiven Scenario that doesn't make use of the given, when, then methods. I found that this test did not appear in the JGiven report, while still being executed.
This actually sounds like the solution you desire, doesn't it?

@adrian-herscu
Copy link
Author

adrian-herscu commented Jul 14, 2020 via email

@l-1squared
Copy link
Collaborator

That is very unfortunate...
Have you been reusing the test stages in tests that you want reported?

@l-1squared
Copy link
Collaborator

So, I have checked whether tests are not reported if you mark all their test steps as hidden. They do.
Given the options that already exist to not report tests, I do not think anything that could be added to JGiven to improve the report selection.
Therefore, I will close the issue

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

3 participants