1

So I have an error that mentioned in the title. Since I was new to testing I decided to follow a tutorial to test my code.

My goal is to see if the there is an item in the list.

Here is my code:

 @Test
    fun WriteAndReadPlant()=runBlocking(){


        val imageUrl = URL(url)
        var options: BitmapFactory.Options? = null
        options = BitmapFactory.Options()
        options.inSampleSize = 3
        val bitmap = BitmapFactory.decodeFile(imageUrl.toString(),
                options)
        val stream = ByteArrayOutputStream()

        bitmap.compress(Bitmap.CompressFormat.PNG, 50, stream)
        val byte_arr: ByteArray = stream.toByteArray()

        val plant = Plant(Math.random().toLong(),"Vera",byte_arr,"Aloe","2 times a week ,Water more in summer","Is not safe to digest for pets")
        dao.insertPlant(plant);

        val plants =dao.getAll() // the data contains in Flow<List<>> type array
        assertThat(plants, contains(plant)).isTrue()// It shows that assertThat method has an error.


    }

Perhaps I'm using wrong method to test to test Flow<List> type array. I tried to find a tutorial that is similar to my goal or solution that I tried to achieve but I didn't find one.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Edita Komarova
  • 193
  • 1
  • 14

0 Answers0