filmov
tv
Unit Testing - ReSharper Essentials
Показать описание
### Testing our Code
Unit tests help make sure code behaves as expected. ReSharper assists with writing and running tests.
### Exploring Unit Tests
* Run Unit Tests
* Debug Unit Tests
* Cover Unit Tests (requires a dotUltimate subscription)
You can manage how unit tests are displayed by clicking the **Group By** icons in the toolbar. By default, ReSharper groups unit tests by project and then namespace. Youcan also group by Target Framework, File System, and, if the unit test frameworks supports it, the test's Category.
From the tool window, you can start a new unit testing session. You can select which tests to run, and then **Create New Session** in the context menu.
### Keyboard Shortcuts
When working with unit tests, keyboard shortcuts can help you be more productive. By default, unit test shortcuts will be a key combination that starts with Ctrl+U (for **U**nit testing). Some shortcuts are context-dependent, others are global. Here are some useful shortcuts to remember:
* Ctrl+U, Ctrl+R run a test, generally from the editor when within the scope of a unit test.
* Ctrl+U, Ctrl+D debug the unit test that's in scope.
* Ctrl+U, Ctrl+L run all unit tests.
* Ctrl+U, Ctrl+Y run the current test session.
* Ctrl+U, Ctrl+U run the previous run, whether it's a session, a group of tests, or a single unit test.
Too much to remember? There's always Alt+Enter to trigger the action menu, where you have the option to run, debug, profile, and cover a single test or test class.
### Session Management
### Run Tests Until Failure
Sometimes, you may have flaky tests - tests that randomly succeed and randomly fail. To troubleshoot flaky tests with ReSharper, you can repeat a test until it fails. Whether an exception occurs in these cases, or an assertion fails, ReSharper will make it visible.
### Continuous Testing and Code Coverage
There's no need to manually rebuild the project and re-run all tests after making changes: the impacted tests are run in the background automatically (the testing session is triggered by some explicit action, for example, saving changes or building the project).
As a result, you get a much faster feedback loop.
### Performance and Memory Profiling with dotTrace and dotMemory
You can profile your unit tests directly from the IDE. We recommend taking a look at the following articles:
Using these approaches, you can assert an application meets certain performance guidelines. You can also write regression tests for performance problems or memory allocations problems, and ensure these don't come back.
### See Also
Unit tests help make sure code behaves as expected. ReSharper assists with writing and running tests.
### Exploring Unit Tests
* Run Unit Tests
* Debug Unit Tests
* Cover Unit Tests (requires a dotUltimate subscription)
You can manage how unit tests are displayed by clicking the **Group By** icons in the toolbar. By default, ReSharper groups unit tests by project and then namespace. Youcan also group by Target Framework, File System, and, if the unit test frameworks supports it, the test's Category.
From the tool window, you can start a new unit testing session. You can select which tests to run, and then **Create New Session** in the context menu.
### Keyboard Shortcuts
When working with unit tests, keyboard shortcuts can help you be more productive. By default, unit test shortcuts will be a key combination that starts with Ctrl+U (for **U**nit testing). Some shortcuts are context-dependent, others are global. Here are some useful shortcuts to remember:
* Ctrl+U, Ctrl+R run a test, generally from the editor when within the scope of a unit test.
* Ctrl+U, Ctrl+D debug the unit test that's in scope.
* Ctrl+U, Ctrl+L run all unit tests.
* Ctrl+U, Ctrl+Y run the current test session.
* Ctrl+U, Ctrl+U run the previous run, whether it's a session, a group of tests, or a single unit test.
Too much to remember? There's always Alt+Enter to trigger the action menu, where you have the option to run, debug, profile, and cover a single test or test class.
### Session Management
### Run Tests Until Failure
Sometimes, you may have flaky tests - tests that randomly succeed and randomly fail. To troubleshoot flaky tests with ReSharper, you can repeat a test until it fails. Whether an exception occurs in these cases, or an assertion fails, ReSharper will make it visible.
### Continuous Testing and Code Coverage
There's no need to manually rebuild the project and re-run all tests after making changes: the impacted tests are run in the background automatically (the testing session is triggered by some explicit action, for example, saving changes or building the project).
As a result, you get a much faster feedback loop.
### Performance and Memory Profiling with dotTrace and dotMemory
You can profile your unit tests directly from the IDE. We recommend taking a look at the following articles:
Using these approaches, you can assert an application meets certain performance guidelines. You can also write regression tests for performance problems or memory allocations problems, and ensure these don't come back.
### See Also