Search
▪️

Testing with Flutter and Dart

작성된 스크립트 내에서 구현된 기능을 test하고 싶을 때 test 폴더에서 별도의 스크립트를 만들어서 test를 한다. 이 때, test할 것들을 따로 import하여 사용하게 된다.
test시에도 void main function이 각각 따로 필요하다.
import 'package:$name/$script.dart;
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart';
import 'package:http/testing.dart';
다음과 같이 test function을 이용한다. test('description', () {setup of test case && expectation});
실제 모듈에서 이용할 때는 Client를 선언하여 썼지만, testing 모듈에서는 Client가 아닌 MockClient를 이용한다.