提交 6ab58951 编写于 作者: 雨爱无痕

add allure-go

上级 74a5709c
......@@ -16,8 +16,8 @@ import (
"time"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
......@@ -26,13 +26,16 @@ var (
successCbRe = regexp.MustCompile("Success to report bug for case \\d+|成功为用例\\d+提交缺陷")
)
type CbSuit struct {
type CbSuite struct {
suite.Suite
testCount uint32
}
func (s *CbSuit) TestCbSuite() {
assert.Equal(s.Suite.T(), "Success", testCb())
func (s *CbSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-cb")
}
func (s *CbSuite) TestCbSuitee(t provider.T) {
t.Require().Equal("Success", testCb())
}
func testCb() string {
......@@ -64,5 +67,5 @@ func TestCb(t *testing.T) {
if runtime.GOOS == "windows" {
cbNewline = "\r\n"
}
suite.Run(t, new(CbSuit))
suite.RunSuite(t, new(CbSuite))
}
......@@ -15,23 +15,27 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
ciNewline = "/"
continueCiRe = regexp.MustCompile("Will commit cases below to Zentao|以下用例信息将被更新到禅道")
successCiRe = regexp.MustCompile("Totally commit 1 cases to Zentao|合计更新1个用例到禅道")
)
type CiSuit struct {
type CiSuite struct {
suite.Suite
testCount uint32
}
func (s *CiSuit) TestCiSuite() {
assert.Equal(s.Suite.T(), "Success", testCi())
func (s *CiSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-ci")
}
func (s *CiSuite) TestCiSuitee(t provider.T) {
t.Require().Equal("Success", testCi())
}
func testCi() string {
......@@ -48,7 +52,7 @@ func testCi() string {
return fmt.Sprintf("expect %s, actual %s", continueCiRe, err.Error())
}
if err = child.Send("y" + newline); err != nil {
if err = child.Send("y" + ciNewline); err != nil {
return err.Error()
}
......@@ -61,7 +65,7 @@ func testCi() string {
func TestCi(t *testing.T) {
if runtime.GOOS == "windows" {
newline = "\r\n"
ciNewline = "\r\n"
}
suite.Run(t, new(CiSuit))
suite.RunSuite(t, new(CiSuite))
}
......@@ -16,22 +16,25 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
successCleanRe = regexp.MustCompile("Successfully cleaned all logs|成功删除所有日志")
)
type CleanSuit struct {
type CleanSuite struct {
suite.Suite
testCount uint32
}
func (s *CleanSuit) TestCleanSuite() {
assert.Equal(s.Suite.T(), "Success", testClean())
func (s *CleanSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-clean")
}
func (s *CleanSuite) TestCleanSuitee(t provider.T) {
t.Require().Equal("Success", testClean())
}
func testClean() string {
......@@ -68,5 +71,5 @@ func testClean() string {
}
func TestClean(t *testing.T) {
suite.Run(t, new(CleanSuit))
suite.RunSuite(t, new(CleanSuite))
}
......@@ -29,9 +29,9 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
......@@ -53,25 +53,28 @@ var (
coNewline = "/"
)
type CoSuit struct {
type CoSuite struct {
suite.Suite
testCount uint32
}
func (s *CoSuit) TestCoProduct() {
assert.Equal(s.Suite.T(), "Success", testCoProduct())
func (s *CoSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-co")
}
func (s *CoSuit) TestCoSuite() {
assert.Equal(s.Suite.T(), "Success", testCoSuite())
func (s *CoSuite) TestCoProduct(t provider.T) {
t.Require().Equal("Success", testCoProduct())
}
func (s *CoSuit) TestCoTask() {
assert.Equal(s.Suite.T(), "Success", testCoTask())
func (s *CoSuite) TestCoSuitee(t provider.T) {
t.Require().Equal("Success", testCoSuitee())
}
func (s *CoSuit) TestCo() {
assert.Equal(s.Suite.T(), "Success", testCo(fmt.Sprintf("ztf co -product %d -language php", productId)))
assert.Equal(s.Suite.T(), "Success", testCo(fmt.Sprintf("ztf co -p %d -m %d -l php", productId, moduleId)))
assert.Equal(s.Suite.T(), "Success", testCo(fmt.Sprintf("ztf co -s %d -l php -i true", suiteId)))
assert.Equal(s.Suite.T(), "Success", testCo(fmt.Sprintf("ztf co -t %d -l php", taskId)))
func (s *CoSuite) TestCoTask(t provider.T) {
t.Require().Equal("Success", testCoTask())
}
func (s *CoSuite) TestCo(t provider.T) {
t.Require().Equal("Success", testCo(fmt.Sprintf("ztf co -product %d -language php", productId)))
t.Require().Equal("Success", testCo(fmt.Sprintf("ztf co -p %d -m %d -l php", productId, moduleId)))
t.Require().Equal("Success", testCo(fmt.Sprintf("ztf co -s %d -l php -i true", suiteId)))
t.Require().Equal("Success", testCo(fmt.Sprintf("ztf co -t %d -l php", taskId)))
}
func testCoProduct() string {
......@@ -136,7 +139,7 @@ func testCoProduct() string {
return "Success"
}
func testCoSuite() string {
func testCoSuitee() string {
cmd := "ztf co"
child, err := expect.Spawn(cmd, -1)
if err != nil {
......@@ -277,5 +280,5 @@ func TestCo(t *testing.T) {
if runtime.GOOS == "windows" {
coNewline = "\r\n"
}
suite.Run(t, new(CoSuit))
suite.RunSuite(t, new(CoSuite))
}
......@@ -16,22 +16,25 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
successCrRe = regexp.MustCompile("Submitted test results to ZenTao|提交测试结果到禅道成功")
)
type CrSuit struct {
type CrSuite struct {
suite.Suite
testCount uint32
}
func (s *CrSuit) TestCrSuite() {
assert.Equal(s.Suite.T(), "Success", testCr())
func (s *CrSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-cr")
}
func (s *CrSuite) TestCrSuitee(t provider.T) {
t.Require().Equal("Success", testCr())
}
func testCr() string {
......@@ -52,8 +55,5 @@ func testCr() string {
}
func TestCr(t *testing.T) {
if runtime.GOOS == "windows" {
newline = "\r\n"
}
suite.Run(t, new(CrSuit))
suite.RunSuite(t, new(CrSuite))
}
......@@ -18,22 +18,25 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
successExpectRe = regexp.MustCompile("Success to create independent expect results file|成功创建独立的期待结果文件")
)
type ExpectSuit struct {
type ExpectSuite struct {
suite.Suite
testCount uint32
}
func (s *ExpectSuit) TestExpectSuite() {
assert.Equal(s.Suite.T(), "Success", testExpect())
func (s *ExpectSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-expect")
}
func (s *ExpectSuite) TestExpectSuitee(t provider.T) {
t.Require().Equal("Success", testExpect())
}
func testExpect() string {
......@@ -73,5 +76,5 @@ expect 3`)
}
func TestExpect(t *testing.T) {
suite.Run(t, new(ExpectSuit))
suite.RunSuite(t, new(ExpectSuite))
}
......@@ -18,22 +18,25 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
successExtractRe = regexp.MustCompile("Success to extract test steps and results|成功从注释提取步骤和期待结果")
)
type ExtractSuit struct {
type ExtractSuite struct {
suite.Suite
testCount uint32
}
func (s *ExtractSuit) TestExtractSuite() {
assert.Equal(s.Suite.T(), "Success", testExtract())
func (s *ExtractSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-extract")
}
func (s *ExtractSuite) TestExtractSuitee(t provider.T) {
t.Require().Equal("Success", testExtract())
}
func testExtract() string {
......@@ -94,5 +97,5 @@ step 10 >> expect 10
}
func TestExtract(t *testing.T) {
suite.Run(t, new(ExtractSuit))
suite.RunSuite(t, new(ExtractSuite))
}
......@@ -18,20 +18,23 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
type ListSuit struct {
type ListSuite struct {
suite.Suite
testCount uint32
}
func (s *ListSuit) TestListSuite() {
assert.Equal(s.Suite.T(), "Success", testLs("ztf list ./demo", regexp.MustCompile("Found 5 test cases|发现5个用例")))
assert.Equal(s.Suite.T(), "Success", testLs("ztf ls ./demo -k 1", regexp.MustCompile("Found 2 test cases|发现2个用例")))
assert.Equal(s.Suite.T(), "Success", testLs("ztf ls demo -k match", regexp.MustCompile("Found 3 test cases|发现3个用例")))
func (s *ListSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-list")
}
func (s *ListSuite) TestListSuitee(t provider.T) {
t.Require().Equal("Success", testLs("ztf list ./demo", regexp.MustCompile("Found 5 test cases|发现5个用例")))
t.Require().Equal("Success", testLs("ztf ls ./demo -k 1", regexp.MustCompile("Found 2 test cases|发现2个用例")))
t.Require().Equal("Success", testLs("ztf ls demo -k match", regexp.MustCompile("Found 3 test cases|发现3个用例")))
}
func testLs(cmd string, successRe *regexp.Regexp) string {
......@@ -52,5 +55,5 @@ func testLs(cmd string, successRe *regexp.Regexp) string {
}
func TestList(t *testing.T) {
suite.Run(t, new(ListSuit))
suite.RunSuite(t, new(ListSuite))
}
......@@ -36,11 +36,11 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file"
"github.com/go-git/go-git/v5"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
......@@ -59,15 +59,19 @@ type RunSuit struct {
testCount uint32
}
func (s *RunSuit) TestRunZtf() {
func (s *RunSuit) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-run")
}
func (s *RunSuit) TestRunZtf(t provider.T) {
for cmd, expectReg := range scriptResMap {
if runtime.GOOS == "windows" {
cmd = strings.ReplaceAll(cmd, "/", "\\")
}
assert.Equal(s.Suite.T(), "Success", testRun(cmd, expectReg))
t.Require().Equal("Success", testRun(cmd, expectReg))
}
}
func (s *RunSuit) TestRunUnitTest() {
func (s *RunSuit) TestRunUnitTest(t provider.T) {
testngDir := "./demo/ci_test_testng"
pytestDir := "./demo/ci_test_pytest"
if runtime.GOOS == "windows" {
......@@ -75,11 +79,11 @@ func (s *RunSuit) TestRunUnitTest() {
pytestDir = ".\\demo\\ci_test_pytest"
}
cloneGit("https://gitee.com/ngtesting/ci_test_testng.git", testngDir)
assert.Equal(s.Suite.T(), "Success", testRunUnitTest("mvn clean package test", testngDir, regexp.MustCompile(`Tests run\: 3, Failures\: 0, Errors\: 0, Skipped\: 0`)))
t.Require().Equal("Success", testRunUnitTest("mvn clean package test", testngDir, regexp.MustCompile(`Tests run\: 3, Failures\: 0, Errors\: 0, Skipped\: 0`)))
cloneGit("https://gitee.com/ngtesting/ci_test_pytest.git", pytestDir)
assert.Equal(s.Suite.T(), "Success", testRunUnitTest("pytest --junitxml=testresult.xml", pytestDir, regexp.MustCompile("1 failed, 1 passed")))
t.Require().Equal("Success", testRunUnitTest("pytest --junitxml=testresult.xml", pytestDir, regexp.MustCompile("1 failed, 1 passed")))
}
......@@ -174,7 +178,7 @@ func testRunUnitTest(cmdStr, workspacePath string, successRe *regexp.Regexp) str
return "Success"
}
func (s *RunSuit) TestRunScenes() {
func (s *RunSuit) TestRunScenes(t provider.T) {
sceneMap := map[string]string{
"exactly empty >> ~~": "",
"exactly start with abc >> ~f:^abc~": "abcdvd",
......@@ -214,18 +218,18 @@ func (s *RunSuit) TestRunScenes() {
for expectVal, actualVal := range sceneMap {
file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
if err != nil {
s.Suite.T().Errorf("open file fail, err:%s", err)
t.Errorf("open file fail, err:%s", err)
return
}
write := bufio.NewWriter(file)
write.WriteString(fmt.Sprintf(template, expectVal, actualVal))
write.Flush()
assert.Equal(s.Suite.T(), "Success", testRun(cmd, regexp.MustCompile(`Run 1 scripts in \d+ sec, 1\(100\.0%\) Pass, 0\(0\.0%\) Fail, 0\(0\.0%\) Skip|执行1个用例,耗时\d+秒。1\(100\.0%\) 通过,0\(0\.0%\) 失败,0\(0\.0%\) 忽略`)))
t.Require().Equal("Success", testRun(cmd, regexp.MustCompile(`Run 1 scripts in \d+ sec, 1\(100\.0%\) Pass, 0\(0\.0%\) Fail, 0\(0\.0%\) Skip|执行1个用例,耗时\d+秒。1\(100\.0%\) 通过,0\(0\.0%\) 失败,0\(0\.0%\) 忽略`)))
file.Close()
}
os.Remove(path)
}
func TestRun(t *testing.T) {
suite.Run(t, new(RunSuit))
suite.RunSuite(t, new(RunSuit))
}
......@@ -19,8 +19,8 @@ import (
"time"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
var (
......@@ -45,17 +45,21 @@ var (
newline = "\n"
)
type SetSuit struct {
type SetSuite struct {
suite.Suite
testCount uint32
}
func (s *SetSuit) TestChSetSuite() {
assert.Equal(s.Suite.T(), "Success", testSet("2"))
func (s *SetSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-set")
}
func (s *SetSuit) TestEnSetSuite() {
assert.Equal(s.Suite.T(), "Success", testSet("1"))
func (s *SetSuite) TestChSetSuitee(t provider.T) {
t.Require().Equal("Success", testSet("2"))
}
func (s *SetSuite) TestEnSetSuitee(t provider.T) {
t.Require().Equal("Success", testSet("1"))
}
func testSet(language string) (ret string) {
......@@ -124,5 +128,5 @@ func TestSet(t *testing.T) {
if runtime.GOOS == "windows" {
newline = "\r\n"
}
suite.Run(t, new(SetSuit))
suite.RunSuite(t, new(SetSuite))
}
......@@ -18,20 +18,23 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
expect "github.com/easysoft/zentaoatf/pkg/lib/expect"
"github.com/stretchr/testify/suite"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
)
type ViewSuit struct {
type ViewSuite struct {
suite.Suite
testCount uint32
}
func (s *ViewSuit) TestViewSuite() {
assert.Equal(s.Suite.T(), "Success", testView("ztf view ./demo/1_string_match_fail.php", regexp.MustCompile("check string matches pattern")))
assert.Equal(s.Suite.T(), "Success", testView("ztf -v ./demo -k 1", regexp.MustCompile("check string matches pattern")))
assert.Equal(s.Suite.T(), "Success", testView("ztf view demo -k match", regexp.MustCompile("Found 3 test cases|发现3个用例")))
func (s *ViewSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("命令行-view")
}
func (s *ViewSuite) TestViewSuitee(t provider.T) {
t.Require().Equal("Success", testView("ztf view ./demo/1_string_match_fail.php", regexp.MustCompile("check string matches pattern")))
t.Require().Equal("Success", testView("ztf -v ./demo -k 1", regexp.MustCompile("check string matches pattern")))
t.Require().Equal("Success", testView("ztf view demo -k match", regexp.MustCompile("Found 3 test cases|发现3个用例")))
}
func testView(cmd string, successRe *regexp.Regexp) string {
......@@ -52,8 +55,5 @@ func testView(cmd string, successRe *regexp.Regexp) string {
}
func TestView(t *testing.T) {
if runtime.GOOS == "windows" {
newline = "\r\n"
}
suite.Run(t, new(ViewSuit))
suite.RunSuite(t, new(ViewSuite))
}
......@@ -7,6 +7,8 @@ cid=1
pid=1
1. exactly match >> ~c:!=2~
2. exactly match >> ~c:!=2~
3. exactly match >> ~c:!=2~
*/
......
......@@ -3,12 +3,22 @@ package main
import (
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/suite"
playwright "github.com/playwright-community/playwright-go"
)
var bugBrowser playwright.Browser
func ScriptBug(t *testing.T) {
type UiBugSuite struct {
suite.Suite
}
func (s *UiBugSuite) BeforeEach(t provider.T) {
t.ID("1579")
t.AddSubSuite("客户端-bug")
}
func (s *UiBugSuite) TestScriptBug(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -80,7 +90,7 @@ func ScriptBug(t *testing.T) {
}
}
func ScriptsBug(t *testing.T) {
func (s *UiBugSuite) TestScriptsBug(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -175,8 +185,6 @@ func ScriptsBug(t *testing.T) {
t.FailNow()
}
}
func TestUiBug(t *testing.T) {
t.Run("ScriptsBug", ScriptBug)
t.Run("ScriptsBug", ScriptsBug)
suite.RunSuite(t, new(UiBugSuite))
}
......@@ -3,12 +3,15 @@ package main
import (
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
var interpreterBrowser playwright.Browser
func CreateInterpreter(t *testing.T) {
func CreateInterpreter(t provider.T) {
t.ID("1579")
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -92,7 +95,7 @@ func CreateInterpreter(t *testing.T) {
t.FailNow()
}
}
func EditInterpreter(t *testing.T) {
func EditInterpreter(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -188,7 +191,7 @@ func EditInterpreter(t *testing.T) {
t.FailNow()
}
}
func DeleteInterpreter(t *testing.T) {
func DeleteInterpreter(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -261,7 +264,7 @@ func DeleteInterpreter(t *testing.T) {
}
func TestUiInterpreter(t *testing.T) {
t.Run("CreateInterpreter", CreateInterpreter)
t.Run("EditInterpreter", EditInterpreter)
t.Run("DeleteInterpreter", DeleteInterpreter)
runner.Run(t, "UiCreateInterpreter", CreateInterpreter)
runner.Run(t, "UiEditInterpreter", EditInterpreter)
runner.Run(t, "UiDeleteInterpreter", DeleteInterpreter)
}
......@@ -3,12 +3,14 @@ package main
import (
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
var languageBrowser playwright.Browser
func SwitchLanguage(t *testing.T) {
func SwitchLanguage(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -70,5 +72,5 @@ func SwitchLanguage(t *testing.T) {
}
func TestUiLanguage(t *testing.T) {
t.Run("SwitchLanguage", SwitchLanguage)
runner.Run(t, "UiSwitchLanguage", SwitchLanguage)
}
......@@ -4,12 +4,14 @@ import (
"strings"
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
var resultBrowser playwright.Browser
func Detail(t *testing.T) {
func Detail(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -66,43 +68,54 @@ func Detail(t *testing.T) {
err = page.Click("#rightPane .result-list-item .list-item-title>>nth=0")
if err != nil {
t.Errorf("Click first result fail: %v", err)
t.FailNow()
}
_, err = page.WaitForSelector(".result-action .btn:has-text('提交结果到禅道')")
if err != nil {
t.Errorf("Wait result tabpage fail: %v", err)
t.FailNow()
}
locator, err = page.Locator(".page-result .single small")
if err != nil {
t.Errorf("Find result percent locator fail: %v", err)
t.FailNow()
}
result, err := locator.InnerText()
if err != nil {
t.Errorf("Find result percent fail: %v", err)
t.FailNow()
}
if result != "通过 0.00%" {
t.Error("Detail result error")
t.FailNow()
}
locator, err = page.Locator(".result-step-checkpoint code")
if err != nil {
t.Errorf("Find result expect locator fail: %v", err)
t.FailNow()
}
expectVal, err := locator.InnerText()
if err != nil {
t.Errorf("Find result expect fail: %v", err)
t.FailNow()
}
if strings.TrimSpace(expectVal) != "~c:!=2~" {
t.Error("Detail expect error")
t.FailNow()
}
locator, err = page.Locator(".result-step-checkpoint code>>nth=1")
if err != nil {
t.Errorf("Find result actual locator fail: %v", err)
t.FailNow()
}
actualVal, err := locator.InnerText()
if err != nil {
t.Errorf("Find result actual fail: %v", err)
t.FailNow()
}
if strings.TrimSpace(actualVal) != "2" {
t.Error("Detail actual error")
t.FailNow()
}
if err = workspaceBrowser.Close(); err != nil {
t.Errorf("The workspaceBrowser cannot be closed: %v", err)
......@@ -114,7 +127,7 @@ func Detail(t *testing.T) {
}
}
func SubmitResult(t *testing.T) {
func SubmitResult(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -181,12 +194,12 @@ func SubmitResult(t *testing.T) {
t.Errorf("Wait syncToZentaoModal fail: %v", err)
t.FailNow()
}
titleInput, err := page.Locator("#syncToZentaoModal>>.form-item:has-text('或输入新任务标题')>>input")
titleInput, err := page.Locator("#syncToZentaoModal>>.form-item:has-text('或输入新测试单标题')>>input")
if err != nil {
t.Errorf("Find title input fail: %v", err)
t.FailNow()
}
err = titleInput.Fill("单元测试任务")
err = titleInput.Fill("单元测试测试单")
if err != nil {
t.Errorf("Fil title input fail: %v", err)
t.FailNow()
......@@ -217,7 +230,7 @@ func SubmitResult(t *testing.T) {
}
}
func SubmitBug(t *testing.T) {
func SubmitBug(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -310,7 +323,7 @@ func SubmitBug(t *testing.T) {
}
}
func SubmitBugTwoStep(t *testing.T) {
func SubmitBugTwoStep(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -405,8 +418,8 @@ func SubmitBugTwoStep(t *testing.T) {
}
func TestUiResult(t *testing.T) {
t.Run("Detail", Detail)
t.Run("SubmitResult", SubmitResult)
t.Run("SubmitBug", SubmitBug)
t.Run("SubmitBugTwoStep", SubmitBugTwoStep)
runner.Run(t, "UiDetail", Detail)
runner.Run(t, "UiSubmitResult", SubmitResult)
runner.Run(t, "UiSubmitBug", SubmitBug)
runner.Run(t, "UiSubmitBugTwoStep", SubmitBugTwoStep)
}
......@@ -5,12 +5,14 @@ import (
"strings"
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
var runBrowser playwright.Browser
func RunScript(t *testing.T) {
func RunScript(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -120,7 +122,7 @@ func RunScript(t *testing.T) {
}
}
func RunSelectedScripts(t *testing.T) {
func RunSelectedScripts(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -254,7 +256,7 @@ func RunSelectedScripts(t *testing.T) {
}
}
func RunOpenedAndLast(t *testing.T) {
func RunOpenedAndLast(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -449,7 +451,7 @@ func RunOpenedAndLast(t *testing.T) {
}
}
func RunAll(t *testing.T) {
func RunAll(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -577,7 +579,7 @@ func RunAll(t *testing.T) {
}
}
func RunReExecFailCase(t *testing.T) {
func RunReExecFailCase(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -698,7 +700,7 @@ func RunReExecFailCase(t *testing.T) {
}
}
func RunReExecAllCase(t *testing.T) {
func RunReExecAllCase(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -819,7 +821,7 @@ func RunReExecAllCase(t *testing.T) {
}
}
func RunFailStatistic(t *testing.T) {
func RunFailStatistic(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -903,7 +905,7 @@ func RunFailStatistic(t *testing.T) {
}
}
func RunSuccessStatistic(t *testing.T) {
func RunSuccessStatistic(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -987,7 +989,7 @@ func RunSuccessStatistic(t *testing.T) {
}
}
func RunBugStatistic(t *testing.T) {
func RunBugStatistic(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -1063,13 +1065,13 @@ func RunBugStatistic(t *testing.T) {
}
func TestUiRun(t *testing.T) {
t.Run("RunScript", RunScript)
t.Run("RunSelectedScripts", RunSelectedScripts)
t.Run("RunOpenedAndLast", RunOpenedAndLast)
t.Run("RunAll", RunAll)
t.Run("RunReExecAllCase", RunReExecAllCase)
t.Run("RunReExecFailCase", RunReExecFailCase)
t.Run("RunSuccessStatistic", RunSuccessStatistic)
t.Run("RunFailStatistic", RunFailStatistic)
t.Run("RunBugStatistic", RunBugStatistic)
runner.Run(t, "UiRunScript", RunScript)
runner.Run(t, "UiRunSelectedScripts", RunSelectedScripts)
runner.Run(t, "UiRunOpenedAndLast", RunOpenedAndLast)
runner.Run(t, "UiRunAll", RunAll)
runner.Run(t, "UiRunReExecAllCase", RunReExecAllCase)
runner.Run(t, "UiRunReExecFailCase", RunReExecFailCase)
runner.Run(t, "UiRunSuccessStatistic", RunSuccessStatistic)
runner.Run(t, "UiRunFailStatistic", RunFailStatistic)
runner.Run(t, "UiRunBugStatistic", RunBugStatistic)
}
......@@ -3,12 +3,14 @@ package main
import (
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
var scriptBrowser playwright.Browser
func SaveScript(t *testing.T) {
func SaveScript(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -115,5 +117,5 @@ func SaveScript(t *testing.T) {
}
func TestUiScript(t *testing.T) {
t.Run("SaveScript", SaveScript)
runner.Run(t, "SaveScript", SaveScript)
}
......@@ -3,12 +3,14 @@ package main
import (
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
var siteBrowser playwright.Browser
func CreateSite(t *testing.T) {
func CreateSite(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -127,7 +129,7 @@ func CreateSite(t *testing.T) {
t.FailNow()
}
}
func EditSite(t *testing.T) {
func EditSite(t provider.T) {
// var timeout float64 = 5000
pw, err := playwright.Run()
if err != nil {
......@@ -259,7 +261,7 @@ func EditSite(t *testing.T) {
t.FailNow()
}
}
func DeleteSite(t *testing.T) {
func DeleteSite(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -341,7 +343,7 @@ func DeleteSite(t *testing.T) {
}
func TestUiSite(t *testing.T) {
t.Run("EditSite", EditSite)
t.Run("DeleteSite", DeleteSite)
t.Run("CreateSite", CreateSite)
runner.Run(t, "EditSite", EditSite)
runner.Run(t, "DeleteSite", DeleteSite)
runner.Run(t, "CreateSite", CreateSite)
}
......@@ -4,6 +4,8 @@ import (
"os"
"testing"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
playwright "github.com/playwright-community/playwright-go"
)
......@@ -12,7 +14,7 @@ var (
workspacePath = pw + "\\demo\\php"
)
func CreateWorkspace(t *testing.T) {
func CreateWorkspace(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -141,7 +143,7 @@ func CreateWorkspace(t *testing.T) {
}
}
func SyncFromZentao(t *testing.T) {
func SyncFromZentao(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -220,7 +222,7 @@ func SyncFromZentao(t *testing.T) {
}
}
func SyncTwoCaseFromZentao(t *testing.T) {
func SyncTwoCaseFromZentao(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -302,7 +304,7 @@ func SyncTwoCaseFromZentao(t *testing.T) {
}
}
func SyncToZentao(t *testing.T) {
func SyncToZentao(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -367,7 +369,7 @@ func SyncToZentao(t *testing.T) {
t.FailNow()
}
}
func Copy(t *testing.T) {
func Copy(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -458,7 +460,7 @@ func Copy(t *testing.T) {
t.FailNow()
}
}
func DeleteScript(t *testing.T) {
func DeleteScript(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -534,7 +536,7 @@ func DeleteScript(t *testing.T) {
t.FailNow()
}
}
func DeleteDir(t *testing.T) {
func DeleteDir(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -611,7 +613,7 @@ func DeleteDir(t *testing.T) {
}
}
func DeleteWorkspace(t *testing.T) {
func DeleteWorkspace(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -677,7 +679,7 @@ func DeleteWorkspace(t *testing.T) {
t.FailNow()
}
}
func Clip(t *testing.T) {
func Clip(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -774,7 +776,7 @@ func Clip(t *testing.T) {
}
}
func FilterDir(t *testing.T) {
func FilterDir(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -848,7 +850,7 @@ func FilterDir(t *testing.T) {
t.FailNow()
}
}
func FilterSuite(t *testing.T) {
func FilterSuite(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -935,7 +937,7 @@ func FilterSuite(t *testing.T) {
t.FailNow()
}
}
func FilterTask(t *testing.T) {
func FilterTask(t provider.T) {
pw, err := playwright.Run()
if err != nil {
t.Error(err)
......@@ -990,7 +992,7 @@ func FilterTask(t *testing.T) {
t.FailNow()
}
page.WaitForTimeout(600)
err = page.Click("#filterModal>>.tab-nav:has-text(\"任务\")")
err = page.Click("#filterModal>>.tab-nav:has-text(\"测试单\")")
if err != nil {
t.Errorf("The Click by suite fail: %v", err)
t.FailNow()
......@@ -1002,7 +1004,7 @@ func FilterTask(t *testing.T) {
t.Errorf("The Click test_task filter fail: %v", err)
t.FailNow()
}
page.WaitForSelector(".toolbar:has-text(\"任务\")")
page.WaitForSelector(".toolbar:has-text(\"测试单\")")
err = page.Click(".tree-node-title:has-text(\"单元测试工作目录\")")
scriptLocator, err := page.Locator(".tree>>text=1_string_match.php")
c, err := scriptLocator.Count()
......@@ -1021,16 +1023,16 @@ func FilterTask(t *testing.T) {
}
}
func TestWorkspace(t *testing.T) {
t.Run("SyncTwoCaseFromZentao", SyncTwoCaseFromZentao)
t.Run("SyncFromZentao", SyncFromZentao)
t.Run("SyncToZentao", SyncToZentao)
t.Run("Copy", Copy)
t.Run("Clip", Clip)
t.Run("DeleteScript", DeleteScript)
t.Run("DeleteDir", DeleteDir)
t.Run("FilterDir", FilterDir)
t.Run("FilterSuite", FilterSuite)
t.Run("FilterTask", FilterTask)
t.Run("DeleteWorkspace", DeleteWorkspace)
t.Run("CreateWorkspace", CreateWorkspace)
runner.Run(t, "SyncTwoCaseFromZentao", SyncTwoCaseFromZentao)
runner.Run(t, "SyncFromZentao", SyncFromZentao)
runner.Run(t, "SyncToZentao", SyncToZentao)
runner.Run(t, "Copy", Copy)
runner.Run(t, "Clip", Clip)
runner.Run(t, "DeleteScript", DeleteScript)
runner.Run(t, "DeleteDir", DeleteDir)
runner.Run(t, "FilterDir", FilterDir)
runner.Run(t, "FilterSuite", FilterSuite)
runner.Run(t, "FilterTask", FilterTask)
runner.Run(t, "DeleteWorkspace", DeleteWorkspace)
runner.Run(t, "CreateWorkspace", CreateWorkspace)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册