Skip to main content
Level 6
September 1, 2022
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
Adobe Employee
September 4, 2022

Can you please share the complete test case?

 

3 replies

arunpatidar
Community Advisor
Community Advisor
September 1, 2022
Pradeep_Kumar_Srivastav
Community Advisor
Community Advisor
September 2, 2022

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

Translate
joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
September 4, 2022

Can you please share the complete test case?

 

Translate