Unverified Commit 0407a318 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Replace clean command test functions with test groups (#51508)

parent cd97f23a
...@@ -18,16 +18,27 @@ import '../../src/common.dart'; ...@@ -18,16 +18,27 @@ import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
void main() { void main() {
void test1() { group('clean command', () {
final MemoryFileSystem fs = MemoryFileSystem(); MockXcode mockXcode;
final MockXcodeProjectInterpreter mockXcodeProjectInterpreter = MockXcodeProjectInterpreter(); setUp(() {
final MockXcode mockXcode = MockXcode(); mockXcode = MockXcode();
});
group('general', () {
MemoryFileSystem fs;
MockXcodeProjectInterpreter mockXcodeProjectInterpreter;
Directory buildDirectory;
FlutterProject projectUnderTest;
setUp(() {
fs = MemoryFileSystem();
mockXcodeProjectInterpreter = MockXcodeProjectInterpreter();
final Directory currentDirectory = fs.currentDirectory; final Directory currentDirectory = fs.currentDirectory;
final Directory buildDirectory = currentDirectory.childDirectory('build'); buildDirectory = currentDirectory.childDirectory('build');
buildDirectory.createSync(recursive: true); buildDirectory.createSync(recursive: true);
final FlutterProject projectUnderTest = FlutterProject.fromDirectory(currentDirectory); projectUnderTest = FlutterProject.fromDirectory(currentDirectory);
projectUnderTest.ios.xcodeWorkspace.createSync(recursive: true); projectUnderTest.ios.xcodeWorkspace.createSync(recursive: true);
projectUnderTest.macos.xcodeWorkspace.createSync(recursive: true); projectUnderTest.macos.xcodeWorkspace.createSync(recursive: true);
...@@ -37,6 +48,7 @@ void main() { ...@@ -37,6 +48,7 @@ void main() {
projectUnderTest.linux.ephemeralDirectory.createSync(recursive: true); projectUnderTest.linux.ephemeralDirectory.createSync(recursive: true);
projectUnderTest.macos.ephemeralDirectory.createSync(recursive: true); projectUnderTest.macos.ephemeralDirectory.createSync(recursive: true);
projectUnderTest.windows.ephemeralDirectory.createSync(recursive: true); projectUnderTest.windows.ephemeralDirectory.createSync(recursive: true);
});
testUsingContext('$CleanCommand removes build and .dart_tool and ephemeral directories, cleans Xcode', () async { testUsingContext('$CleanCommand removes build and .dart_tool and ephemeral directories, cleans Xcode', () async {
when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
...@@ -57,11 +69,14 @@ void main() { ...@@ -57,11 +69,14 @@ void main() {
Xcode: () => mockXcode, Xcode: () => mockXcode,
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter, XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
}); });
} });
group('Windows', () {
MockPlatform windowsPlatform;
setUp(() {
windowsPlatform = MockPlatform();
});
void test2() {
final MockXcode mockXcode = MockXcode();
final MockPlatform windowsPlatform = MockPlatform();
testUsingContext('$CleanCommand prints a helpful error message on Windows', () async { testUsingContext('$CleanCommand prints a helpful error message on Windows', () async {
when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(false); when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(false);
when(windowsPlatform.isWindows).thenReturn(true); when(windowsPlatform.isWindows).thenReturn(true);
...@@ -94,10 +109,8 @@ void main() { ...@@ -94,10 +109,8 @@ void main() {
Platform: () => windowsPlatform, Platform: () => windowsPlatform,
Xcode: () => mockXcode, Xcode: () => mockXcode,
}); });
} });
});
test1();
test2();
} }
class MockFile extends Mock implements File {} class MockFile extends Mock implements File {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment