Код: Выделить всё
// Usings and namespace have been abbreviated away.
[TestFixture]
public class Foo
{
private Bar? _bar;
[SetUp]
public void Setup()
{
_bar = DoApiRequest("endpoint"); // The problem here is that the API request needs to be tested itself, also this can be anything, not just an API request.
// ...
}
// Other tests
// ...
}
Код: Выделить всё
// Usings and namespace have been abbreviated away.
[TestFixture]
public class Foo
{
private Bar? _bar;
[SetUp]
public void Setup()
{
_bar = DoApiRequest("endpoint"); // The problem here is that the API request needs to be tested.
// Assert code here which makes the setup basically a test itself that other tests depend on.
// ...
}
// Other tests
// ...
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -of-a-test