1

是否可以使用相同的场景来测试不同的条目,其中一些会导致“正确”成功,而另一些会导致“正确”失败?如果行为正确,测试就可以了。
例如,登录连接应该在一个数据条目上成功,而在另一个条目上应该失败,但测试必须以成功结束。

4

1 回答 1

0

是的,这个样本存在于 NoraUi 的 CI 中:

https://github.com/NoraUi/NoraUi/blob/master/src/test/resources/data/in/hello.csv

author;zip;city;element;element2;date;title;Result
Jenkins T1;35000;Rennes;smile;smile;16/01/2050;;
Jenkins T2;75000;Paris;smile;smile;;;31
Jenkins T3;56100;Lorient;smile;smile;;;25
Jenkins T4;35000;Rennes;smile;smile;;;
Jenkins T5;35000;Rennes;noExistElement;noExistElement;;;42
Jenkins T6;35000;;smile;smile;;;2
Jenkins T7;35000;Rennes;;;;;4
Jenkins T8;;Rennes;;smile;smile;;58

您可以在列中找到 KO 步数Result(输入数据提供者)。

例如:

Jenkins T5;35000;Rennes;noExistElement;noExistElement;;;42

https://github.com/NoraUi/NoraUi/blob/master/src/test/resources/steps/hello.feature的第 42 步是 KO 与noExistElement

When I click on $bakery.DemoPage-<element>

在你的 CI 之后:

https://noraui.github.io/#continuousIntegration

travis-ci 在线示例(unix 批处理示例使用 SED):https ://github.com/NoraUi/NoraUi/blob/master/test/run.sh

echo "***************************************************"
echo "** Integration tests verification                **"
echo "***************************************************"

counters1=$(sed -n 's:.*\[Excel\] > <EXPECTED_RESULTS_1>\(.*\)</EXPECTED_RESULTS_1>.*:\1:p' nonaui.log | head -n 1)
echo "******** $counters1"
nb_counters1=$(sed -n ":;s/$counters1//p;t" nonaui.log | sed -n '$=')
echo "********" found $nb_counters1 times

counters2=$(sed -n 's:.*\[Excel\] > <EXPECTED_RESULTS_2>\(.*\)</EXPECTED_RESULTS_2>.*:\1:p' nonaui.log | head -n 1)
echo "******** $counters2"
nb_counters2=$(sed -n ":;s/$counters2//p;t" nonaui.log | sed -n '$=')
echo "******** found $nb_counters2 times"

# 3 = 1 (real) + 2 counters (Excel and CSV)
if [ "$nb_counters1" == "3" ] && [ "$nb_counters2" == "3" ]; then
    echo "******** All counter is SUCCESS"
else
    echo "******** All counter is FAIL"
    echo "$counters1 found $nb_counters1 times"
    echo "$counters2 found $nb_counters2 times"
    pwd
    ls -l
    cat target/reports/html/index.html
    exit 255
fi

echo "***************************************************"
echo "** Unit tests verification                       **"
echo "***************************************************"

counterFailures=$(sed -n 's/.*\[\(.*\)\] Tests run: \(.*\), Failures: \([1-9]\), Errors: \(.*\), Skipped: \(.*\), Time elapsed.*UT.*/\3/p' nonaui.log | head -n 1)
echo "******** counter Failures: $counterFailures"

counterErrors=$(sed -n 's/.*\[\(.*\)\] Tests run: \(.*\), Failures: \(.*\), Errors: \([1-9]\), Skipped: \(.*\), Time elapsed.*UT.*/\4/p' nonaui.log | head -n 1)
echo "******** counter Errors: $counterErrors"

if [ "$counterFailures" == "" ] && [ "$counterErrors" == "" ]; then
    echo "******** All unit test are SUCCESS"
else
    if [ "$counterFailures" != "" ]; then
        echo "******** At least one unit test is Failure"
    fi
    if [ "$counterErrors" != "" ]; then
        echo "******** At least one unit test is Error"
    fi
    exit 255
fi 
于 2020-03-31T14:25:38.693 回答