Skip to content

Commit c3d1513

Browse files
committed
feature: integration tests
1 parent fdde738 commit c3d1513

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

Diff for: lib/src/bin/preview_builder/preview_builder.dart

+19-13
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class ${clazz}Test {
252252
);
253253
}
254254

255-
Future<TestBuilderInfo> generateInstrumentedTest(
255+
Future<TestBuilderInfo> generateIntegrationTest(
256256
dynamic config,
257257
String srcPath,
258258
String className,
@@ -264,25 +264,25 @@ Future<TestBuilderInfo> generateInstrumentedTest(
264264
String fileName = srcPath.split('/').last;
265265
String name = fileName.split('.').first;
266266
String dirPath = srcPath.replaceAll(fileName, '');
267-
String testPath = '${dirPath}catalog/instrumented_test/';
267+
String testPath = '${dirPath}catalog/integration_test/';
268268

269269
await Directory(testPath).create(recursive: true);
270270

271-
String testFile = '$testPath${name}_instrumented_test.dart';
271+
String testFile = '$testPath${name}_integration_test.dart';
272272
File file = File(testFile);
273273

274274
var importParts = classImport.split('/');
275275
importParts.removeAt(importParts.length - 1);
276276
importParts.add(config['output']);
277-
importParts.add('instrumented_test');
278-
importParts.add('${name}_instrumented_test.dart');
277+
importParts.add('integration_test');
278+
importParts.add('${name}_integration_test.dart');
279279

280280
if (await file.exists()) {
281281
print(
282-
'🧪 👌 Test file already exist for $clazz - ${clazz}InstrumentedTest ($testFile)');
282+
'🧪 👌 Test file already exist for $clazz - ${clazz}IntegrationTest ($testFile)');
283283
return TestBuilderInfo(
284284
alias: buildTestAlias(4),
285-
clazzName: '${clazz}InstrumentedTest',
285+
clazzName: '${clazz}IntegrationTest',
286286
import: importParts.join('/'),
287287
);
288288
}
@@ -300,10 +300,10 @@ import 'package:catalog/catalog.dart';
300300
import '../dummy/$name.dummy.dart';
301301
import '../preview/$name.$prefix.dart';
302302
303-
class ${clazz}InstrumentedTestTest {
303+
class ${clazz}IntegrationTestTest {
304304
void main() {
305305
group(
306-
'$clazz - InstrumentedTest Tests',
306+
'$clazz - IntegrationTest Tests',
307307
() {
308308
testWidgets(
309309
'Lorem text not found',
@@ -337,7 +337,7 @@ class ${clazz}InstrumentedTestTest {
337337

338338
return TestBuilderInfo(
339339
alias: buildTestAlias(4),
340-
clazzName: '${clazz}InstrumentedTest',
340+
clazzName: '${clazz}IntegrationTest',
341341
import: importParts.join('/'),
342342
);
343343
}
@@ -368,13 +368,19 @@ void main() {
368368
await file.writeAsString(content);
369369
}
370370

371-
Future<void> generateMainInstrumentedTest(
371+
Future<void> generateMainIntegrationTest(
372372
String basePath,
373373
List<TestBuilderInfo> tests,
374374
) async {
375-
File file = File('./${basePath}instrumented_test/catalog_widget_instrumented_test.dart');
376375

377-
print('🧪 Updating catalog instrumented test collector (${file.path})');
376+
String testPath = './${basePath}integration_test/';
377+
378+
await Directory(testPath).create(recursive: true);
379+
380+
381+
File file = File('./${basePath}integration_test/catalog_widget_integration_test.dart');
382+
383+
print('🧪 Updating catalog integration test collector (${file.path})');
378384

379385
var content = '''
380386
/// AUTOGENERATED FILE. DO NOT EDIT

Diff for: lib/src/bin/tasks/tasks/instrumented_test_task.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class InstrumentedTestTask extends BaseTask {
5555
if (className == null) continue;
5656
if (preview == null) continue;
5757

58-
final testFile = await generateInstrumentedTest(
58+
final testFile = await generateIntegrationTest(
5959
config,
6060
file.path,
6161
className,
@@ -66,6 +66,6 @@ class InstrumentedTestTask extends BaseTask {
6666
test.add(testFile);
6767
}
6868

69-
await generateMainInstrumentedTest(base, test);
69+
await generateMainIntegrationTest(base, test);
7070
}
7171
}

0 commit comments

Comments
 (0)