JUnit for BufferedReader | Community
Skip to main content
Level 6
Sep 1, 2022 12:40 PM UTC
Solved

JUnit for BufferedReader

new BufferedReader(new InputStreamReader(<inputStremObject>, StandardCharsets.UTF_8))

I have mocked InputStream, InputStreamReader and BufferedReader and I'm fetching a JSON file asset. <bufferedReaderObject>.readLine() throws IOException (error msg: Underlying input stream returned zero bytes) in my test file. How do I handle this JUnit scenario?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Sep 4, 2022 8:14 AM UTC

Can you please share the complete test case?

 

3 replies

joerghoh
joerghohAccepted solution
Employee
Sep 4, 2022 8:14 AM UTC

Can you please share the complete test case?

 

Translate
Pradeep_Kumar_Srivastav
New Participant
Sep 2, 2022 12:42 AM UTC

Hi @shaheena_sheikh for BufferedReader IO exception you can use  https://www.javafixing.com/2021/11/fixed-junit-test-for-inputstreamreader.html 

Translate
arunpatidar
New Participant
Sep 1, 2022 2:59 PM UTC