Я внедрил собственный тип теста для Visual Studio. Пользовательский тип теста считывает свои тестовые элементы из dll. Моя реализация ITip работает как шарм. Элементы тестирования загружаются и отображаются в окне инструмента Test View.Устранение проблемы с FileNotFound при запуске настраиваемого типа теста для Visual Studio
Когда я выбираю тестовые элементы и запускаю их, они попадают в состояние «Не выполнено». Отлаживая эту проблему, я обнаружил, что исключение FileNotFoundException выбрано из QTAgent32.exe. Он говорит мне, что он не может найти DLL, которая определяет тестовые примеры. Кроме того, он терпит неудачу перед вызовом моего TestAdapter.Initialize. Я скопировал свою тестовую DLL в каталог PrivateAssemblies Visual studio. Когда я делаю это, мои тестовые элементы проходят. Я также могу отлаживать код в своем тестовом адаптере. Итак, смысл всего этого в том, что QTAgent32.exe не может найти свою тестовую DLL в ее исходной директории.
Мой вопрос: что мне делать, чтобы QTAgent32 нашел свою тестовую dll в исходном каталоге? Для completenes добавить свою Подсказку код метода Load:
public override ICollection Load(string location, ProjectData projectData, IWarningHandler warningHandler)
{
Trace.WriteLine("Started RegexTestTip Load.");
if (string.IsNullOrEmpty(location))
{
throw new ArgumentException("File location was not specified!", "location");
}
var fileInfo = new FileInfo(location);
if (!fileInfo.Exists)
{
throw new ErrorReadingStorageException(
string.Format("Could not find a file on the specified location: {0}", location));
}
var result = new List<ITestElement>();
var extension = fileInfo.Extension.ToLower();
if (extension != ".dll")
{
return result;
}
Assembly testAssembly = Assembly.LoadFrom(location);
var testClasses = testAssembly.GetTypes().
Where(t => Attribute.IsDefined(t, typeof(RegexTestClassAttribute)));
foreach (Type testClass in testClasses)
{
PropertyInfo property = testClass.GetProperties().
SingleOrDefault(p => Attribute.IsDefined(p, typeof(TestedRegexAttribute)));
if (property == null || !TestedRegexAttribute.Validate(property))
{
throw new InvalidDataInStorageException("A Regex test must define a Tested Regex property with type Regex");
}
var testCases = testClass.GetProperties().
Where(p => Attribute.IsDefined(p, typeof(RegexTestCaseAttribute)));
foreach (PropertyInfo testCase in testCases)
{
if (!RegexTestCaseAttribute.Validate(testCase))
{
throw new InvalidDataInStorageException("A test case property must return a String value.");
}
var testElement = new RegexTestElement(property, testCase);
testElement.Storage = location;
testElement.Name = testCase.Name;
testElement.Description = "A simple description";
testElement.ProjectData = projectData;
result.Add(testElement);
}
}
Trace.WriteLine("Finished RegexTestTip Load.");
return result;
}
Всегда подчеркивайте вопрос, чтобы понять ключевые моменты очень быстро :) –
@Venkat - что вы имеете в виду выделить? Сделать это смелым? – Ikaso