e2e testing made eas(y/ier)
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

70 wiersze
1.3KB

  1. #!/usr/bin/ruby
  2. require 'watir'
  3. require 'watir-scroll'
  4. require 'zeitwerk'
  5. loader = Zeitwerk::Loader.new
  6. loader.push_dir __dir__.concat '/../lib'
  7. loader.push_dir Dir.pwd.concat '/pokes'
  8. loader.setup
  9. # @brief main
  10. #
  11. # @param argv: Array
  12. # @param argc: Integer
  13. #
  14. # @return ?
  15. # @since 0.1
  16. #
  17. # @todo let the developer provide the list of tests that are ran
  18. def main argv = [], argc
  19. if argv.include? '--server'
  20. Server.run!
  21. return false
  22. end
  23. Thread.new {
  24. Server.run!
  25. }
  26. Thread.new {
  27. Fx::pipe(
  28. { headless: ARGV.first != 'visible',
  29. options: {
  30. args: [ 'start-fullscreen' ]
  31. }
  32. },
  33. -> (opts) {
  34. Watir::Browser.new :firefox,
  35. opts
  36. },
  37. -> (b) {
  38. Watir.default_timeout = 10
  39. b.window.resize_to 1366, 768
  40. Tests.constants.each do |c|
  41. k = Tests.const_get(c)
  42. if !(k.is_a? Class)
  43. next
  44. end
  45. k.methods(false).sort.each do |m|
  46. if "assert" != m[0..5]
  47. next
  48. end
  49. Fx::perform k.method(m), b, "#{c}::#{m}"
  50. end
  51. end
  52. # todo: if Server.running?
  53. Server.stop!
  54. })
  55. }.join
  56. end
  57. main ARGV, ARGV.count