From 23b646c2131c681a2083bd8cc9633a81228a53b1 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Thu, 26 May 2016 17:00:42 +0300 Subject: [PATCH] appium-test macro Former-commit-id: 54ae25dc67ec9ca2d75e87f8b62637c4c8592c43 --- test/status_im/appium.clj | 10 +++++++++- test/status_im/console.clj | 14 ++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/status_im/appium.clj b/test/status_im/appium.clj index 7a857711de..d2ff6adb53 100644 --- a/test/status_im/appium.clj +++ b/test/status_im/appium.clj @@ -50,7 +50,7 @@ (.getText (by-xpath driver xpath))) (defn xpath-by-text [text] - (str ".//*[@text='" text "']" )) + (str ".//*[@text='" text "']")) (defn contains-text [driver text] (is (= 1 (->> (xpath-by-text text) @@ -59,3 +59,11 @@ (defn quit [driver] (.quit driver)) + +(defmacro appium-test [name & body] + (let [sym (gensym)] + `(deftest ~name + (let [~sym (init)] + ~@(for [[f & rest] body] + `(~f ~sym ~@rest)) + (quit ~sym))))) diff --git a/test/status_im/console.clj b/test/status_im/console.clj index 4d748af7c2..5cdf17ae45 100644 --- a/test/status_im/console.clj +++ b/test/status_im/console.clj @@ -7,11 +7,9 @@ " the exclamation mark or hit the icon to open the command " "list and choose the !phone command")) -(deftest console-test - (let [driver (init)] - (click driver :request-keypair-password) - (write driver :command-input "123") - (click driver :stage-command) - (click driver :send-message) - (contains-text driver message-text) - (quit driver))) +(appium-test console-test + (click :request-keypair-password) + (write :command-input "123") + (click :stage-command) + (click :send-message) + (contains-text message-text))