-
Notifications
You must be signed in to change notification settings - Fork 1
8. Tests & Developers Tips
- Be sure you have backed up the database before you are going to test since the test will delete the whole database(or at least some collection) to make a propro test. In is recommended to test on a separate (inactive) Firebase project.
Since getxfire is a bit complicated and depends on many other packages, we found out that the standard unit testing is not an ideal option. So, we wrote our own simple unit test code.
You can add the code below in Home screen. You need to fix the import path.
- To do unit test of chat
import 'file:///Users/thruthesky/apps/dating/packages/getxfire/test/chat.tests.v2.dart';GetxFire ff = GetxFire();
ff.init({});
ChatTest(inject: ff).runTests();
Test code creates chat room with hatch option and leaves out of the room, the test may produce unhandled exception if you do not run test code in order. The best wayy to test the code is to remove the chat collection from firestore and run full test code.
After test, you need to remove the code from main.dart
Please read Testing Flutter apps for details about Flutter app testing.
We don't do unit testing on getxfire since its backend is Firebase and there is no doubt about Firebase's performance and quality assurance.
And we don't do widget testing. Instead, we do integration test.
-
See sample app's intergration-test branch for the codes.
-
We have tested it on Android app only since iOS app displays push notification consent box and it annoys the test.
-
Youtube video on integration test
- You may delete user account from Firebase Auth menu to register with same phone number.
- To write an extension method, see the example below.
import 'package:getxfire/getxfire.dart';
extension on GetxFire {
getUid() {
return user.uid;
}
}
print('uid: ' + ff.getUid());
You can do so much things with Fireflutter. We will introduce some scenario how getxfire could extend your app's functionality.
Imagine that you are going to build a social app. User can upload his photos and manage it on his profile page while those photos are public. User can see other users' photos and take actions like voting(like and dislike), commeting, and even reporting for abusement.
- You can create a forum named
gallary
and putadd photo
button in user's profile screen. - When user uploads a photo with firelfutter upload method, create a post under gallery forum with getxfire method.
- You can, then, get(listen) user's photo with getxfire post fetch method and display it to screen.
- When user wants edit or delete photo, do so with getxfire.
This may cause lots of time and effort to accomplish without getxfire.
Sometimes you may want to keep the deleted post. Imagine that you are going to build a photo gallery and keeping history of uploaded photos are mandatory.
- When user deletes a post which has the photo,
- Don't delete the document. Instead delete the title and content, add a property
{deleted: FieldValue.serverTimestamp()}
- And when the app lists the posts, hide deleted posts.
- Buy Me a Coffee : https://www.buymeacoffee.com/faisalramdan17
- Contact us on Telegram : https://t.me/faisalramdan17
- Website: https://codingyourlife.id
- GitHub: https://github.com/faisalramdan17
- Facebook : https://www.facebook.com/codingyourlife.id
- Instagram: https://instagram.com/faisalramdan17 & https://instagram.com/codingyourlife.id
- LinkedIn: https://www.linkedin.com/in/faisalramdan17