This is a piece of test code made for the Angular application.

The router object is a mock provided by the RouterTestingModule dependency. I wonder if such a test can be considered a unit test (because it actually tests only one element and the fact that it calls some method - without checking its result), or should it be called an integration test (due to the fact that it still call external dependence)?

it('should trigger the navigation to `/home`', async(() => {
  const link = fixture.debugElement.nativeElement.querySelector('.home-link');




closed as off-topic by 200_success, Toby Speight, Peter Taylor, Heslacher, pacmaninbw Jul 3 at 13:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – 200_success, Toby Speight
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Welcome to Code Review! Did you create this code or do you maintain it? \$\endgroup\$ – Sᴀᴍ Onᴇᴌᴀ Jul 2 at 22:55
  • \$\begingroup\$ Welcome to Code Review! The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles. \$\endgroup\$ – Toby Speight Jul 3 at 7:10
  • 2
    \$\begingroup\$ I'm voting to close this question as off-topic because it isn't asking for code review \$\endgroup\$ – Peter Taylor Jul 3 at 7:53


  • router object is a mock, and
  • the fact that it calls some method - without checking its result

You have a unit test, more specifically a whitebox test, as opposed to a blackbox test that tests the output of some method.

For it to become an integration test, you would have use a router instead of a mock.


Not the answer you're looking for? Browse other questions tagged or ask your own question.