如何使用Jenkins运行编码的UI测试

时间:2018-06-27 11:46:51

标签: visual-studio jenkins continuous-integration jenkins-pipeline coded-ui-tests

嗨,我是jenkin的新手,正在尝试配置jenkins以运行编码的UI测试。 我正在使用Windows Batch命令行在jenkins中运行编码的ui。

当我执行该命令时,命令已成功执行,但所有测试均因此错误消息而失败。 “为测试类CodedUITestProject5.CodedUITest1调用初始化方法时出错:Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException:要运行与桌面交互的测试,必须将测试代理设置为作为交互式进程运行。有关更多信息,请参阅“如何:设置测试代理以运行与桌面交互的测试”

下面是我的窗口批处理命令 cd C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Common7 \ IDE mstest.exe / testcontainer:“ C:\ Users \ pmallika \ Documents \ Visual Studio 2015 \ Projects \ CodedUITestProject5 \ CodedUITestProject5 \ bin \ Debug \ CodedUITestProject5.dll” /结果文件:“ C:\ Users \ pmallika \ Documents \ Visual Studio 2015 \ Projects \ CodedUITestProject5 \ pp.trx“

Jenkins的控制台输出

正在加载C:\ Users \ pmallika \ Documents \ Visual Studio 2015 \ Projects \ CodedUITestProject5 \ CodedUITestProject5 \ bin \ Debug \ CodedUITestProject5.dll ... 开始执行...

结果顶级测试 ------- --------------- CodedUITestProject5.CodedUITest1.CodedUITestMethod1失败 CodedUITestProject5.CodedUITest1.CodedUITestMethod2失败 CodedUITestProject5.CodedUITest1.CodedUITestMethod3失败 0/3个测试通过,3个失败

摘要

测试运行失败。   失败3


总计3

我厌倦了使用MSTEST插件运行已编码的ui测试,

我用相同的命令行累了运行单元测试,并且成功运行了。

2 个答案:

答案 0 :(得分:1)

您正在字符串中搜索两个单独的项目。如果你把它们分成一个列表,那么下面的代码会找到它们。


lk = [ 'Motor','101' ]
s1 = [ 'Device Motor_101 is very high',
       '101Motor Device is very high',
       'Motor device 101 is very is high' ]

for i, a in enumerate( s1 ):
    result = -1
    for b in a.split():
        if lk[0] in b:
            result = i
        if lk[1] in b:
            if result > -1:
                print( f'found in {a}' )

此代码将搜索并找到不止两个项目


lk = [ 'Motor','101' ]
ln = len( lk )
s1 = [ 'Device Motor_101 is very high',
       '101Motor Device is very high',
       'Motor device 101 is very is high' ]

found = []
for i, a in enumerate( s1 ):
    for b in a.split():
        result = -1
        for gp in range( ln ):
            if lk[ gp ] in b:
                result += 1
        if result > -1 and found.count( a ) == 0:
            found.append( a )
            print( f'found in {a}' )
print( f'{found}' )

好的,我发现重复的单词会导致误报,所以... 这是我的第三次尝试


lk = [ 'sky', '101', 'Motor', 'very' ]
ln = len( lk )
s1 = [ 'Device Motor_101 is very high in sky',
       '101Motor Device is sky sky very',
       'Motor device is very is high very very' ]

found = []
for i, a in enumerate( s1 ):
    result = 0
    sa = a.split( )
    for b in a.split():
        for gp in range( ln ):
            if lk[ gp ] in b:
                if b in sa:
                    sa.remove( b )
                    result += 1
    if result == ln-1:
        found.append( a )

print( f'{found}' )

答案 1 :(得分:0)

您需要分别搜索 Motor101,如果两者都存在,则返回状态。

def get_match(s):
    lookup = ['Motor', '101']
    count = 0
    for i in lookup:
        if i in s:
            count += 1
        if count == len(lookup):
            return 'Strings Present'
    return 'Not Present'

    

print(get_match('Device Motor_101 is very high'))
print(get_match('Stackoverflow 101'))
print(get_match('101Motor Device is very high'))
print(get_match('Motor device 101 is very is high'))
print(get_match('Motorbikes are good'))
Output:

Strings Present
Not Present
Strings Present
Strings Present
Not Present
相关问题