4

I'd like to find some new conceptual ideas, but specific solutions are welcome.

Technologies

  • Versioning System: SVN
  • Continuous Integration Tool: TeamCity
  • Agent: Windows (no admin rights!)
  • Language: Java
  • WebDriver: InternetExplorerDriver
  • Testing: JUnit
  • Build: ant

Problem

If someone stops a configuration (line in TeamCity GUI) while it is running, the afterClass method is not executed (it closes the browser) and the browser becomes residual.

Structure

enter image description here

(beforeClass starts the driver and afterClass closes it)

Flow

enter image description here

( where you see a red arrow, someone stops the configuration -> E.g.: (s)he observed that a test failed and wants to run it again, but it produces a residual browser because afterClass is not executed )

Previous attempts

  • Go to the agent and restart it manually ( 1 time / 1-4 weeks ) - works, but has important disadvantages
  • Go to the agent and tried to use taskkill and taskkill /F - doesn't work
  • Other Java attempts (to run a "cleaner" before the tests - native Windows commands), but without success

Do you have any ideas? They can be related to the agent, TeamCity, Java code, ant, specific configurations, etc.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
  • Id look at junit rules TestWatcher and intercept the fail and quit driver accordingly. – bcar Oct 18 '14 at 14:51

1 Answers1

1

If I understand the question correctly, stopping of configuration is killing the jvm, leaving the browsers residual. Am I correct? If so, you could try adding shutdown hooks and handle the closing of browsers in the shutdown hook. i.e. you could put the browser closing block of code in a method and invoke that from both shutdown hook and afterClass, with proper exception handling.

I hope this answer helps you.

BasavarajM
  • 31
  • 4