Parcourir la source

test: use run_all.py script to run all test

wangweimin il y a 5 ans
Parent
commit
597b42a1f6
3 fichiers modifiés avec 31 ajouts et 1 suppressions
  1. 2 1
      .github/workflows/test.yml
  2. 9 0
      test/Readme.md
  3. 20 0
      test/run_all.py

+ 2 - 1
.github/workflows/test.yml

@@ -17,6 +17,7 @@ jobs:
       - name: Percy Test
         uses: percy/exec-action@v0.2.0
         with:
-          custom-command: "npx percy exec -- python3 test/1.basic_output.py auto"
+          custom-command: "python3 test/run_all.py"
+          verbose: true
         env:
           PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}

+ 9 - 0
test/Readme.md

@@ -1,4 +1,13 @@
 ## Test
+使用 selenium 进行 + percy 进行测试。
+
+测试的原理为使用selenium打开编写的PyWebIO测试服务,在页面上进行模拟操作,
+将一些时刻的网页快照使用percy进行保存,percy可以比较不同提交之间的相同页面的区别。
+
+### 编写测试用例
+// todo
+
+### 运行测试用例
 
 ```bash
 pip3 install -e ".[dev]" 

+ 20 - 0
test/run_all.py

@@ -0,0 +1,20 @@
+from os import path
+
+import os
+
+here_dir = path.dirname(path.abspath(__file__))
+
+
+def run_all_test():
+    """顺序运行所有测试用例"""
+    files = [f for f in os.listdir(here_dir) if path.isfile(f) and f.split('.', 1)[0].isdigit()]
+    files.sort(key=lambda f: int(f.split('.', 1)[0]))
+
+    for f in files:
+        file = path.join(here_dir, f)
+        print("Run test script: %s" % file)
+        os.system("npx percy exec -- python3 %s auto" % file)
+
+
+if __name__ == '__main__':
+    run_all_test()