Skip to content

Commit 9bd6fb0

Browse files
stereotype441copybara-github
authored andcommitted
Remove mockito pre-null-safety tests.
Now that all source code in google3 has been migrated to use Dart language version 2.12 or greater, this test case isn't needed anymore. Removing it helps unblock the removal of legacy (pre-null-safety) support from the Dart analyzer. PiperOrigin-RevId: 590334278
1 parent 57a7c82 commit 9bd6fb0

File tree

2 files changed

+0
-164
lines changed

2 files changed

+0
-164
lines changed

test/builder/auto_mocks_test.dart

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,6 @@ void main() {}
7979
void main() {
8080
late InMemoryAssetWriter writer;
8181

82-
/// Test [MockBuilder] in a package which has not opted into null safety.
83-
Future<void> testPreNonNullable(Map<String, String> sourceAssets,
84-
{Map<String, /*String|Matcher<String>*/ Object>? outputs,
85-
Map<String, dynamic> config = const <String, dynamic>{}}) async {
86-
final packageConfig = PackageConfig([
87-
Package('foo', Uri.file('/foo/'),
88-
packageUriRoot: Uri.file('/foo/lib/'),
89-
languageVersion: LanguageVersion(2, 7))
90-
]);
91-
await testBuilder(buildMocks(BuilderOptions(config)), sourceAssets,
92-
writer: writer, outputs: outputs, packageConfig: packageConfig);
93-
}
94-
9582
/// Test [MockBuilder] in a package which has opted into null safety.
9683
Future<void> testWithNonNullable(Map<String, String> sourceAssets,
9784
{Map<String, /*String|Matcher<List<int>>*/ Object>? outputs,
@@ -3375,65 +3362,6 @@ void main() {
33753362
);
33763363
});
33773364

3378-
test('given a pre-non-nullable library, includes an opt-out comment',
3379-
() async {
3380-
await testPreNonNullable(
3381-
{
3382-
...annotationsAsset,
3383-
...simpleTestAsset,
3384-
'foo|lib/foo.dart': dedent(r'''
3385-
abstract class Foo {
3386-
int f(int a);
3387-
}
3388-
'''),
3389-
},
3390-
outputs: {'foo|test/foo_test.mocks.dart': _containsAllOf('// @dart=2.9')},
3391-
);
3392-
});
3393-
3394-
test('given a pre-non-nullable library, does not override any members',
3395-
() async {
3396-
await testPreNonNullable(
3397-
{
3398-
...annotationsAsset,
3399-
...simpleTestAsset,
3400-
'foo|lib/foo.dart': dedent(r'''
3401-
abstract class Foo {
3402-
int f(int a);
3403-
}
3404-
'''),
3405-
},
3406-
outputs: {
3407-
'foo|test/foo_test.mocks.dart': _containsAllOf(dedent('''
3408-
class MockFoo extends _i1.Mock implements _i2.Foo {
3409-
MockFoo() {
3410-
_i1.throwOnMissingStub(this);
3411-
}
3412-
}
3413-
'''))
3414-
},
3415-
);
3416-
});
3417-
3418-
test('given a pre-non-nullable library, overrides toString if necessary',
3419-
() async {
3420-
await testPreNonNullable(
3421-
{
3422-
...annotationsAsset,
3423-
...simpleTestAsset,
3424-
'foo|lib/foo.dart': dedent(r'''
3425-
abstract class Foo {
3426-
String toString({bool a = false});
3427-
}
3428-
'''),
3429-
},
3430-
outputs: {
3431-
'foo|test/foo_test.mocks.dart': _containsAllOf(
3432-
'String toString({bool a = false}) => super.toString();')
3433-
},
3434-
);
3435-
});
3436-
34373365
test(
34383366
'adds ignore: must_be_immutable analyzer comment if mocked class is '
34393367
'immutable', () async {

test/builder/custom_mocks_test.dart

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,6 @@ MockFoo() {
8989
void main() {
9090
late InMemoryAssetWriter writer;
9191

92-
/// Test [MockBuilder] in a package which has not opted into null safety.
93-
Future<void> testPreNonNullable(Map<String, String> sourceAssets,
94-
{Map<String, /*String|Matcher<String>*/ Object>? outputs}) async {
95-
final packageConfig = PackageConfig([
96-
Package('foo', Uri.file('/foo/'),
97-
packageUriRoot: Uri.file('/foo/lib/'),
98-
languageVersion: LanguageVersion(2, 7))
99-
]);
100-
await testBuilder(buildMocks(BuilderOptions({})), sourceAssets,
101-
outputs: outputs, packageConfig: packageConfig);
102-
}
103-
10492
/// Builds with [MockBuilder] in a package which has opted into null safety,
10593
/// returning the content of the generated mocks library.
10694
Future<String> buildWithNonNullable(Map<String, String> sourceAssets) async {
@@ -622,34 +610,6 @@ void main() {
622610
expect(mocksContent, contains('returnValueForMissingStub: 0,'));
623611
});
624612

625-
test(
626-
'generates mock methods with non-nullable return types, specifying '
627-
'legal default values for basic known types, in mixed mode', () async {
628-
final mocksContent = await buildWithNonNullable({
629-
...annotationsAsset,
630-
'foo|lib/foo.dart': dedent(r'''
631-
abstract class Foo {
632-
int m({required int x, double? y});
633-
}
634-
'''),
635-
'foo|test/foo_test.dart': '''
636-
// @dart=2.9
637-
import 'package:foo/foo.dart';
638-
import 'package:mockito/annotations.dart';
639-
640-
@GenerateMocks(
641-
[],
642-
customMocks: [
643-
MockSpec<Foo>(onMissingStub: OnMissingStub.returnDefault),
644-
],
645-
)
646-
void main() {}
647-
'''
648-
});
649-
expect(mocksContent, contains('returnValue: 0,'));
650-
expect(mocksContent, contains('returnValueForMissingStub: 0,'));
651-
});
652-
653613
test(
654614
'generates mock methods with non-nullable return types, specifying '
655615
'legal default values for unknown types', () async {
@@ -1273,58 +1233,6 @@ void main() {
12731233
);
12741234
});
12751235

1276-
test('given a pre-non-nullable library, does not override any members',
1277-
() async {
1278-
await testPreNonNullable(
1279-
{
1280-
...annotationsAsset,
1281-
...simpleTestAsset,
1282-
'foo|lib/foo.dart': dedent(r'''
1283-
abstract class Foo {
1284-
int f(int a);
1285-
}
1286-
'''),
1287-
},
1288-
outputs: {
1289-
'foo|test/foo_test.mocks.dart': _containsAllOf(dedent('''
1290-
class MockFoo extends _i1.Mock implements _i2.Foo {
1291-
$_constructorWithThrowOnMissingStub
1292-
}
1293-
'''))
1294-
},
1295-
);
1296-
});
1297-
1298-
test(
1299-
'given a pre-non-nullable safe library, does not write "?" on interface '
1300-
'types', () async {
1301-
await testPreNonNullable(
1302-
{
1303-
...annotationsAsset,
1304-
...simpleTestAsset,
1305-
'foo|lib/foo.dart': dedent('''
1306-
abstract class Foo<T> {
1307-
int f(int a);
1308-
}
1309-
'''),
1310-
'foo|test/foo_test.dart': dedent('''
1311-
import 'package:foo/foo.dart';
1312-
import 'package:mockito/annotations.dart';
1313-
@GenerateMocks(
1314-
[], customMocks: [MockSpec<Foo<int>>(as: #MockFoo)])
1315-
void main() {}
1316-
'''),
1317-
},
1318-
outputs: {
1319-
'foo|test/foo_test.mocks.dart': _containsAllOf(dedent('''
1320-
class MockFoo extends _i1.Mock implements _i2.Foo<int> {
1321-
$_constructorWithThrowOnMissingStub
1322-
}
1323-
'''))
1324-
},
1325-
);
1326-
});
1327-
13281236
test(
13291237
'generates a mock class which uses the new behavior of returning '
13301238
'a valid value for missing stubs, if GenerateNiceMocks were used',

0 commit comments

Comments
 (0)