Java Unit Test Read File

Hi everyone,

I am new to using Unit Test. I saw a YouTube video for Coding Rooms that allows the teacher to test if the student code contains a specifc String. I tried it in a repl but could not get it to work.

Here is his code:

I tried using the code but could not get it to work. I think it is because of the header in my repl. I could NOT type “throws Exception”.

Please help…

Thank you,

Hello @TylerTrinh and welcome to the community!

Could you please share the repl to your code so we can analyse and check if everything is ok?

You can check this guide about how to share your code.

My Repl Linkis >>>

Hopefully you are able to see my code as well as the unit test that I need help with.

I ran the unit test and got the following error message:

Installing imported packages
Failed to compile test runner file

./ error: unreported exception IOException; must be caught or declared to be thrown
      String student_code = new String(Files.readAllBytes(Paths.get("")));
Note: ./ uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

exit status 1

Is this a private repl? I clicked the link and got a 404

1 Like

I believe all of my Repls are public, but I might have forgotten to publish it. I believe it should be okay now for you to access.

Thanks for your time.

“This person doesn’t have any Repls yet!”