I am trying to write unit tests for methods that load and add data from Firebase DB. I have not found any resources to help me with this. can someone point me to a resource or post a sample code? for example, this is my load method
public ArrayList getGroceryData(final String type) {
tempBuilder=new ArrayList<>();
test=false;
databaseReference.child("Tasks").child(type).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot d : dataSnapshot.getChildren()) {
tempBuilder.add(d.getValue(Task.class));
}
test=true;
// Dashboard.populatefeed(tempBuilder);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
while(!test);
test=false;
return tempBuilder;
}