无法在testcomplete中运行自动化项目。
在我们的持续集成部分中,项目使用testcomplete进行自动化,并且在bat文件的帮助下通过jenkins进行调用.bat文件中的脚本是
"C:\Program Files\Automated QA\TestComplete 7\Bin\TestComplete.exe " "D:\Test Complete7 Projects\ProjectInput_AllSamples\ProjecInputs.pjs" /r /p:Samples /rt:Main "iexplore" /e
它将打开testcomplete和iexplorer,但它没有填充数据(自动化)。 当我们用jenkins直接调用bat文件时,它工作正常。是否有任何解决方案
答案 0 :(得分:1)
如果您将Jenkins(主服务器或从服务器)作为Windows服务运行,请确保它以用户身份运行,而不是作为本地系统运行。
我们也和Gentlesea的建议一样,我们在Jenkins Slaves上运行TestExecute,并为设计TestComplete脚本的人员保留TestComplete许可证。
答案 1 :(得分:1)
从您的描述中可以看出,Windows中的某些内容阻止您允许测试应用程序正常工作。可能是第二个用户可能是一个问题,但我无法确认,因为我无法找到它在Windows XP中如何工作的明确解释。我很确定这不会在Windows Vista,7,8或服务器上运行,但由于changes in architecture。
听起来最好的解决方案是确保您的自动UI测试由交互式用户启动。当我尝试在我们的构建中添加自动化测试时,我们在Windows XP SP2虚拟机上使用了TestComplete 7。为了以交互式用户身份开始我们的测试,我们:
我们写了一个小应用程序,会在交互式用户登录时启动。此应用程序将查看特定文件,当该文件更改/创建时,它将读取该文件并启动该应用程序。这个应用程序的代码看起来像这样:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ApplicationStarter
{
class Program
{
// The string used to indicate that the application should quit.
private const string ExitString = "exit";
// The path which is being watched for changes.
private static string s_LoadFilePath;
static void Main(string[] args)
{
try
{
{
Debug.Assert(
args != null,
"The arguments array should not be null.");
Debug.Assert(
args.Length == 1,
"There should only be one argument.");
}
s_LoadFilePath = args[0];
{
Console.WriteLine(
string.Format(
CultureInfo.InvariantCulture,
"Watching: {0}",
s_LoadFilePath));
}
if (File.Exists(s_LoadFilePath))
{
RunApplication(s_LoadFilePath);
}
using (var watcher = new FileSystemWatcher())
{
watcher.IncludeSubdirectories = false;
watcher.NotifyFilter =
NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.FileName
| NotifyFilters.DirectoryName;
watcher.Path = Path.GetDirectoryName(s_LoadFilePath);
watcher.Filter = Path.GetFileName(s_LoadFilePath);
try
{
watcher.Created += OnConfigFileCreate;
watcher.EnableRaisingEvents = true;
// Now just sit here and wait until hell freezes over
// or until the user tells us that it has
string line = string.Empty;
while (!string.Equals(line, ExitString, StringComparison.OrdinalIgnoreCase))
{
line = Console.ReadLine();
}
}
finally
{
watcher.Created -= OnConfigFileCreate;
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private static void RunApplication(string configFilePath)
{
var appPath = string.Empty;
var arguments = string.Empty;
using (var reader = new StreamReader(configFilePath, Encoding.UTF8))
{
appPath = reader.ReadLine();
arguments = reader.ReadLine();
}
// Run the application
StartProcess(appPath, arguments);
}
private static void StartProcess(string path, string arguments)
{
var startInfo = new ProcessStartInfo();
{
startInfo.FileName = path;
startInfo.Arguments = arguments;
startInfo.ErrorDialog = false;
startInfo.UseShellExecute = true;
startInfo.RedirectStandardOutput = false;
startInfo.RedirectStandardError = false;
}
Console.WriteLine(
string.Format(
CultureInfo.InvariantCulture,
"{0} Starting process {1}",
DateTime.Now,
path));
using (var exec = new Process())
{
exec.StartInfo = startInfo;
exec.Start();
}
}
private static void OnConfigFileCreate(
object sender,
FileSystemEventArgs e)
{
Console.WriteLine(
string.Format(
CultureInfo.InvariantCulture,
"{0} File change event ({1}) for: {2}",
DateTime.Now,
e.ChangeType,
e.FullPath));
// See that the file is there. If so then start the app
if (File.Exists(e.FullPath) &&
string.Equals(s_LoadFilePath, e.FullPath, StringComparison.OrdinalIgnoreCase))
{
// Wait for a bit so that the file is no
// longer locked by other processes
Thread.Sleep(500);
// Now run the application
RunApplication(e.FullPath);
}
}
}
}
这个应用程序希望文件有两行,第一行是你要启动的应用程序,第二行是参数,所以在你的情况下是这样的:
C:\Program Files\Automated QA\TestComplete 7\Bin\TestComplete.exe
"D:\Test Complete7 Projects\ProjectInput_AllSamples\ProjecInputs.pjs" /r /p:Samples /rt:Main "iexplore" /e
您应该能够在构建步骤中从Jenkins生成此文件。
最后,您可能需要观看TestComplete流程以便退出,以便您可以在结束时获取结果,但我会将其作为练习留给读者。