-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

aidy wrote:
> Hi,
> 
> All my GUI test classes contain this code within the constructor.
> 
> class ST_MSE_33
>   def initialize
> 
>     start_browser
>     login
> 
>    ................
> 
>     rescue => e
>      p "test failed: #{e.message}"
>      p   e.backtrace
>     ensure
>      log_out
>      close_window
>   end
> end
> 
> That is, there is always the same start and same end, but a different
> middle.
> Is there any way I could use inheritance to avoid duplication?

I would use the following construct:

class GeneralBehaviour
  def initialize
    start_browser
    login

    specific_behaviour

    ...
  end

  # this is only necessary if GeneralBehaviour can be used
  # on its own
  def specific_behaviour
  end
end

class SpecifB1 < GeneralBehaviour
  def specific_behaviour
    # do sth specific ;)
  end
end

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFE9rUj9S2Eui6zfdQRAtN5AKCcjVXYZeUi/Qh1iM3SOay52hLc8gCcDMgc
4FXA0QPUVqzhFVzr3C6icCY=
=arYe
-----END PGP SIGNATURE-----