Skip to content

Commit 9ed196f

Browse files
authored
Move many test files to test_reflective_loader (#3284)
1 parent ce25524 commit 9ed196f

15 files changed

+1013
-1197
lines changed

pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dev_dependencies:
3939
test: ^1.19.0
4040
test_descriptor: ^2.0.0
4141
test_process: ^2.0.2
42+
test_reflective_loader: ^0.2.0
4243

4344
executables:
4445
dartdoc: null

test/analysis_options.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include: ../analysis_options.yaml
2+
3+
linter:
4+
rules:
5+
# For reflective test naming
6+
non_constant_identifier_names: false

test/annotation_test.dart

+19-59
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,25 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/file_system/memory_file_system.dart';
65
import 'package:dartdoc/src/model/model.dart';
7-
import 'package:dartdoc/src/package_config_provider.dart';
8-
import 'package:dartdoc/src/package_meta.dart';
96
import 'package:test/test.dart';
7+
import 'package:test_reflective_loader/test_reflective_loader.dart';
108

11-
import 'src/test_descriptor_utils.dart' as d;
9+
import 'dartdoc_test_base.dart';
1210
import 'src/utils.dart';
1311

1412
void main() {
15-
const libraryName = 'annotations';
16-
17-
const dartCoreUrlPrefix = 'https://api.dart.dev/stable/2.16.0/dart-core';
18-
19-
late PackageMetaProvider packageMetaProvider;
20-
late MemoryResourceProvider resourceProvider;
21-
late FakePackageConfigProvider packageConfigProvider;
22-
late String packagePath;
23-
24-
setUp(() async {
25-
packageMetaProvider = testPackageMetaProvider;
26-
resourceProvider =
27-
packageMetaProvider.resourceProvider as MemoryResourceProvider;
28-
29-
packagePath = await d.createPackage(
30-
libraryName,
31-
pubspec: '''
32-
name: annotations
33-
version: 0.0.1
34-
environment:
35-
sdk: '>=2.15.0 <3.0.0'
36-
''',
37-
resourceProvider: resourceProvider,
38-
);
39-
40-
packageConfigProvider =
41-
getTestPackageConfigProvider(packageMetaProvider.defaultSdkDir.path);
42-
packageConfigProvider.addPackageToConfigFor(
43-
packagePath, libraryName, Uri.file('$packagePath/'));
13+
defineReflectiveSuite(() {
14+
defineReflectiveTests(AnnotationTest);
4415
});
16+
}
4517

46-
Future<Library> bootPackageWithLibrary(String libraryContent) async {
47-
await d.dir('lib', [
48-
d.file('lib.dart', '''
49-
library $libraryName;
50-
51-
$libraryContent
52-
'''),
53-
]).createInMemory(resourceProvider, packagePath);
54-
55-
var packageGraph = await bootBasicPackage(
56-
packagePath,
57-
packageMetaProvider,
58-
packageConfigProvider,
59-
);
60-
return packageGraph.libraries.named(libraryName);
61-
}
18+
@reflectiveTest
19+
class AnnotationTest extends DartdocTestBase {
20+
@override
21+
final libraryName = 'annotations';
6222

63-
test('deprecated constant is linked', () async {
23+
void test_deprecatedConstant() async {
6424
var library = await bootPackageWithLibrary('''
6525
@deprecated
6626
int value = 0;
@@ -76,9 +36,9 @@ int value = 0;
7636
annotation.linkedNameWithParameters,
7737
'@<a href="$dartCoreUrlPrefix/deprecated-constant.html">deprecated</a>',
7838
);
79-
});
39+
}
8040

81-
test('Deprecated() constructor call is linked', () async {
41+
void test_DeprecatedConstructorCall() async {
8242
var library = await bootPackageWithLibrary('''
8343
@Deprecated('text')
8444
int value = 0;
@@ -95,9 +55,9 @@ int value = 0;
9555
'@<a href="$dartCoreUrlPrefix/Deprecated-class.html">Deprecated</a>'
9656
'(&#39;text&#39;)',
9757
);
98-
});
58+
}
9959

100-
test('locally declared constant is linked', () async {
60+
void test_locallyDeclaredConstant() async {
10161
var library = await bootPackageWithLibrary('''
10262
class MyAnnotation {
10363
const MyAnnotation();
@@ -121,9 +81,9 @@ int value = 0;
12181
'@<a href="${htmlBasePlaceholder}annotations/myAnnotation-constant.html">'
12282
'myAnnotation</a>',
12383
);
124-
});
84+
}
12585

126-
test('locally declared constructor call is linked', () async {
86+
void test_locallyDeclaredConstructorCall() async {
12787
var library = await bootPackageWithLibrary('''
12888
class MyAnnotation {
12989
const MyAnnotation(bool b);
@@ -145,9 +105,9 @@ int value = 0;
145105
'@<a href="${htmlBasePlaceholder}annotations/MyAnnotation-class.html">'
146106
'MyAnnotation</a>(true)',
147107
);
148-
});
108+
}
149109

150-
test('generic constructor call is linked', () async {
110+
void test_genericConstructorCall() async {
151111
var library = await bootPackageWithLibrary('''
152112
class Ann<T> {
153113
final T f;
@@ -172,5 +132,5 @@ int value = 0;
172132
'<span class="signature">&lt;<wbr><span class="type-parameter">'
173133
'<a href="$dartCoreUrlPrefix/bool-class.html">bool</a></span>&gt;</span>(true)',
174134
);
175-
});
135+
}
176136
}

0 commit comments

Comments
 (0)