JetBrains Rider 2023.3 Help

Test Linker

In this category, you can specify options for linking tests and tested code when you navigate between those.

Use affix search

JetBrains Rider links test classes whose names start or end with the specified affixes to the corresponding classes in tested code. Clear this checkbox to ignore test class names and use other heuristics for navigation.

Use attribute-based search

JetBrains Rider links test classes annotated with a specific attribute to the corresponding classes in tested code.

JetBrains Rider always takes into account the [TestSubject] attribute from JetBrains.Annotations. For example, if you navigate from a class named SampleClass, tests annotated with [TestSubject(typeof(SampleClass))] will be suggested as navigation destinations.

If you annotate tests with another attribute to link them to tested classes, specify the fully-qualified name of this attribute to take it into account in addition to [TestSubject]. Note that you can only specify one attribute per solution.

Clear this checkbox to ignore attributes and use other heuristics for navigation.

Use generic argument search

JetBrains Rider links test classes with tested classes when the base test class has a generic parameter that represents the tested class, and this generic parameter is annotated with a specifc attribute.

Consider the following example:

[TestFixture] public abstract class TestsFor<[MeansTestSubject] T> { private AutoMock myMock; public T Component => myMock.Create<T>(); } public class TestsForSampleClass : TestsFor<SampleClass> { [Test] public void TestSample() { Component.DoSomething(); } }

In this example, generic parameter T is annotated with the [MeansTestSubject] attribute from JetBrains.Annotations. This attribute is always taken into account in such scenarios. If you use another attribute for these purposes, specify its fully-qualified name to take it into account in addition to [MeansTestSubject]. Note that you can only specify one attribute per solution.

Clear this checkbox to ignore generic arguments and use other heuristics for navigation.

Creation of unit tests

In this category, you can specify options for creation of unit tests.

Test class naming convention

This option defines what name should be suggested for the created test class. The first affix specified in the Test class affixes field above will be used.

Annotate with test subject mention

This selector defines in which cases the created test class should be annotated with the attribute that helps link it with the tested class. If the attribute should be added, JetBrains Rider will use the attribute specified in the Attribute name for test subject mentions field above or the [TestSubject] attribute from JetBrains.Annotations if that field is empty.

You can choose between the following options:

  • Never: created tests will not be not annotated.

  • When not evident: created tests will not be annotated if a base test class is used with a generic argument that represents the tested class (see option Use generic argument search above).

  • When cannot be inferred from name: created tests will not be annotated if the test name includes the name of the tested class and has either a suffix or prefix that match one of the affixes specified in the Test class affixes field above.

  • When cannot be inferred: created tests will not be not annotated if the link to the tested class can be inferred either from name or from the generic argument.

  • Always: created tests will always be annotated.

Last modified: 29 February 2024