Update BlocTest authored by Nicholas Sarian's avatar Nicholas Sarian
In a BlocTest, you can test the bloc, state, and event simultaneously since they are interdependent. To test the bloc in isolation, the test requires the creation of mocks, which can be generated with the @GenerateMocks annotation. You'll prepare your test like this:
The purpose of creating a bloc test is to check the flow of states as they are being emitted.
To test the bloc in isolation, the test requires the creation of mocks, which can be generated with the @GenerateMocks annotation. You'll prepare your test like this:
```dart
class PlayerRepositoryTest extends Mock implements PlayerRepository {}
@GenerateMocks([PlayerRepositoryTest])
```
However, note that @GenerateMocks only generates the mock classes during compile time, and therefore you need to execute a command in the terminal to generate the mocks.dart file. To generate the mocks.dart file, use the following command:
However, note that @GenerateMocks only generates the mock classes during compile time, and therefore you need to execute a command in the terminal to generate the mocks.dart file. To generate the mocks.dart file, run the following command:
```
flutter pub run build_runner build
```
It's worth noting that every time you make a change to the repository or bloc, you have to rerun this command to recreate the new mocks with the new changes.
# How to Test a Bloc, State, and Event
......
......