Checking the unit tests of ScholarX backend

In the ScholarX backend, some unit tests are missing so we need to add those tests. Previously we had created unit tests for most of the endpoints and service methods. Since few months I noticed that the tests don’t run when building the backend. So I checked the backend and found that the unit tests are in the wrong directory.

But after moving it to the right directory, it throws errors because some controllers and methods have changed.

The swagger UI is also not working now, so we have to fix that too.

To add the missing unit tests, we have to do these things:

  1. Fix the directory
  2. Fix the existing tests
  3. Fix the swagger UI
  4. Find out the missing unit tests
  5. Add the missing tests
1 Like

Thanks @piumal1999 for having a look at this task.
Shall we break down these steps into issues.
My suggestion is,

  1. Issue for dir fix.
  2. Individual issues for each endpoint to fix the existing unit tests.
  3. Individual issues for each endpoint to add missing tests.
  4. Issue for Swagger UI fix.
    test issues should mention to add tests(if missing) for the controller and its service methods.

Yeah. That’s a good suggestion.

So we can also assign the new contributors for those

Btw, I tried fixing the directory issue. But before merging, we have to fix the existing tests from that PR. previously we had nearly 100 unit tests, and most of them are failing due to endpoint changes. I was able to fix 50 of them. For the rest, I need to find a way to create a mock authentication principal.

Draft PR:

1 Like

I was able to fix the authentication issue in unit tests. What I did was creating an authentication principal manually in the tests.

Updated the Pull request.

Next we’ll have to find the missing tests and add those. I’ll create a document with available and missing unit test details