Skip to content

Commit 509482b

Browse files
authored
Use the test project in the missing test tool (#2308)
* Use the test project in the missing test tool * use var * fix
1 parent 73a6419 commit 509482b

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

lib/PuppeteerSharp.Tooling/IdentifyMissingTests.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using System.Linq;
2929
using System.Reflection;
3030
using PuppeteerSharp.Nunit;
31+
using PuppeteerSharp.Tests;
3132

3233
namespace PuppeteerSharp.Tooling
3334
{
@@ -54,26 +55,24 @@ public static void Run(IdentifyMissingTestsOptions options)
5455
// let's map the test cases from the spec files
5556
MapTestsCases(directoryInfo, options, string.Empty);
5657

57-
// now, let's load the DLL and use some reflection-fu
58-
var assembly = Assembly.LoadFrom(options.TestsAssemblyPath);
59-
60-
var attributes = assembly.DefinedTypes.SelectMany(
61-
type => type.GetMethods().SelectMany(method => method.GetCustomAttributes<PuppeteerTestAttribute>()));
62-
6358
var potentialMatches = 0;
6459
var fullMatches = 0;
6560
var noMatches = 0;
6661
var totalTests = 0;
6762

6863
List<PuppeteerTestAttribute> missingTests = new();
6964
List<KeyValuePair<PuppeteerTestAttribute, List<PuppeteerTestAttribute>>> invalidMaps = new();
65+
66+
var attributes = new ScreenshotHelper().GetType().Assembly .DefinedTypes.SelectMany(
67+
type => type.GetMethods().SelectMany(method => method.GetCustomAttributes<PuppeteerTestAttribute>()));
68+
7069
foreach (var x in _testPairs)
7170
{
7271
totalTests++;
7372

7473
// a test can either be a full match, a partial (i.e. just the test name) or no match
7574
var potentialMatch = attributes.Where(atx => string.Equals(x.TestName, atx.TestName, StringComparison.InvariantCultureIgnoreCase))
76-
.Where(atx => string.Equals(x.Describe, atx.Describe, StringComparison.InvariantCultureIgnoreCase));
75+
.Where(atx => string.Equals(x.Describe, atx.Describe, StringComparison.InvariantCultureIgnoreCase));
7776
if (!potentialMatch.Any())
7877
{
7978
noMatches++;

lib/PuppeteerSharp.Tooling/Options/IdentifyMissingTestsOptions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ namespace PuppeteerSharp.Tooling
3232
[Verb("missing-tests", HelpText = "Checks if there are missing tests in the C# variant, compared to the specs.")]
3333
internal class IdentifyMissingTestsOptions
3434
{
35-
[Option(Required = true, HelpText = "Location of the PuppeteerShar.Tests assembly.")]
36-
public string TestsAssemblyPath { get; set; }
37-
3835
[Option(Required = true, HelpText = "Location of spec files.")]
3936
public string SpecFileLocations { get; set; }
4037

lib/PuppeteerSharp.Tooling/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal static class Program
3333
{
3434
internal static void Main(string[] args)
3535
{
36-
ParserResult<object> result = Parser.Default.ParseArguments<ScaffoldTestOptions, IdentifyMissingTestsOptions>(args);
36+
var result = Parser.Default.ParseArguments<ScaffoldTestOptions, IdentifyMissingTestsOptions>(args);
3737
result.WithParsed<ScaffoldTestOptions>(ScaffoldTest.Run);
3838
result.WithParsed<IdentifyMissingTestsOptions>(IdentifyMissingTests.Run);
3939
}

lib/PuppeteerSharp.Tooling/PuppeteerSharp.Tooling.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
</ItemGroup>
2121
<ItemGroup>
2222
<ProjectReference Include="..\PuppeteerSharp.Nunit\PuppeteerSharp.Nunit.csproj" />
23+
<ProjectReference Include="..\PuppeteerSharp.Tests\PuppeteerSharp.Tests.csproj" />
2324
</ItemGroup>
2425
</Project>

0 commit comments

Comments
 (0)