Conversation
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; |
There was a problem hiding this comment.
Подозреваю, что всё это не нужно
| public void ThrowsExpectedException() | ||
| { | ||
| throw new ArgumentException(); | ||
| } |
There was a problem hiding this comment.
Если это тестовый класс, это не повод не соблюдать стайлгайд :) Используйте =>, шапку с лицензией и всё такое.
|
|
||
| public class LifecycleTest | ||
| { | ||
| public static List<string> Loger = new List<string>(); |
There was a problem hiding this comment.
Он должен быть "Logger" по идее, и второй List<string> можно не писать.
| public void ResetStat() | ||
| { | ||
| Loger.Clear(); | ||
| } |
There was a problem hiding this comment.
Тут тем более стоит использовать =>
| [Test] | ||
| public void BasicTests_ShouldIdentifySpecificity() | ||
| { | ||
| var result = this.runner!.RunTest(this.path!); |
There was a problem hiding this comment.
Проинициализировали бы runner и path какими-то значениями, чтобы сделать их ненуллабельными и тут ! не писать. ! тут явно не по делу.
| try | ||
| { | ||
| instance = Activator.CreateInstance(testClass); | ||
| this.RunBeforeAndAfterMethods(testClass, instance!, typeof(BeforeAttribute)); |
There was a problem hiding this comment.
Не используйте ! в "боевом" коде.
| catch (TargetInvocationException) | ||
| { | ||
| throw; | ||
| } |
There was a problem hiding this comment.
Это кажется что абсолютно бессмысленная конструкция, поймали исключение и тут же перебросили его же
| } | ||
| } | ||
|
|
||
| this.RunBeforeAndAfterMethods(testClass, instance!, typeof(AfterAttribute)); |
There was a problem hiding this comment.
Тут тоже могут быть исключения и тест надо пометить как Errored — даже если он прошёл, всё равно чинить тесты надо.
| this.RunSingleTest(testClass, testMethod, results, assemblyName); | ||
| } | ||
|
|
||
| this.RunStaticMethods(testClass, typeof(AfterClassAttribute), out _); |
| return results.ToList(); | ||
| } | ||
|
|
||
| private bool RunStaticMethods(Type type, Type attributeType, out string? error) |
There was a problem hiding this comment.
out-параметры вроде как не нужны в современном C#, возвращайте лучше кортеж. Правильнее всего было бы вообще размеченное объединение Success | Error of string, но C# такого не умеет, а делать аналог вручную слишком громоздко.
No description provided.