Skip to main content

Is trackUserPerformance within the data access layer?

If no, then you should consider adding the layer. A common—although not the only one—approach is to separate applications into presentation layer, which handles all the UI logic, business layer, which contains the actual logic of the application, and the data access layer which provides persistence.

If yes, you should consider whether unit tests are the most appropriate here, or other types of tests should be used instead. If you rely on unit tests, then the actual database would be mocked, possibly by tampering with the db property. If you prefer system tests instead, i.e. tests where the actual database will be changed, then either use nested transactions (i.e. the test itself will start a parent transaction and revert it once the code is executed) or snapshots. It takes milliseconds to restore a snapshot, so it shouldn't affect too negatively the speed of the tests.

  • If no, then you should consider adding the layer. A common—although not the only one—approach is to separate applications into following layers:

    1. presentation layer, which handles all the UI logic

    2. business layer, which contains the actual logic of the application

    3. data access layer which provides persistence.

  • If yes, you should consider whether unit tests are the most appropriate here, or other types of tests should be used instead.

    1. If you rely on unit tests, then the actual database would be mocked, possibly by tampering with the db property.

    2. If you prefer system tests instead, i.e. tests where the actual database will be changed, then either use nested transactions (i.e. the test itself will start a parent transaction and revert it once the code is executed) or snapshots. It takes milliseconds to restore a snapshot, so it shouldn't affect too negatively the speed of the tests.

Is trackUserPerformance within the data access layer?

If no, then you should consider adding the layer. A common—although not the only one—approach is to separate applications into presentation layer, which handles all the UI logic, business layer, which contains the actual logic of the application, and the data access layer which provides persistence.

If yes, you should consider whether unit tests are the most appropriate here, or other types of tests should be used instead. If you rely on unit tests, then the actual database would be mocked, possibly by tampering with the db property. If you prefer system tests instead, i.e. tests where the actual database will be changed, then either use nested transactions (i.e. the test itself will start a parent transaction and revert it once the code is executed) or snapshots. It takes milliseconds to restore a snapshot, so it shouldn't affect too negatively the speed of the tests.

Is trackUserPerformance within the data access layer?

  • If no, then you should consider adding the layer. A common—although not the only one—approach is to separate applications into following layers:

    1. presentation layer, which handles all the UI logic

    2. business layer, which contains the actual logic of the application

    3. data access layer which provides persistence.

  • If yes, you should consider whether unit tests are the most appropriate here, or other types of tests should be used instead.

    1. If you rely on unit tests, then the actual database would be mocked, possibly by tampering with the db property.

    2. If you prefer system tests instead, i.e. tests where the actual database will be changed, then either use nested transactions (i.e. the test itself will start a parent transaction and revert it once the code is executed) or snapshots. It takes milliseconds to restore a snapshot, so it shouldn't affect too negatively the speed of the tests.

Source Link
Arseni Mourzenko
  • 135.5k
  • 31
  • 349
  • 521

Is trackUserPerformance within the data access layer?

If no, then you should consider adding the layer. A common—although not the only one—approach is to separate applications into presentation layer, which handles all the UI logic, business layer, which contains the actual logic of the application, and the data access layer which provides persistence.

If yes, you should consider whether unit tests are the most appropriate here, or other types of tests should be used instead. If you rely on unit tests, then the actual database would be mocked, possibly by tampering with the db property. If you prefer system tests instead, i.e. tests where the actual database will be changed, then either use nested transactions (i.e. the test itself will start a parent transaction and revert it once the code is executed) or snapshots. It takes milliseconds to restore a snapshot, so it shouldn't affect too negatively the speed of the tests.