-
Notifications
You must be signed in to change notification settings - Fork 0
Framework Attributes
This page is a run-down of all the attributes within the Edison.Framework
library. There will be a quick description of each, and then a simple example.
- Author
- Category
- Concurrency
- Description
- ExpectedException
- Ignore
- ParallelRepeat
- ParallelTestCase
- Repeat
- SetupFixture
- Slack
- Suite
- TestCase
- Version
Usage: Methods, Classes
Multiple: Yes
This attribute allows you to specify the author(s) of the test. This could be left as the original author, or updated to include additional author attributes for the person who last modified the test.
The author(s) of a test can be later accessed via the TestResult object on Teardown.
[Test]
[Author("Matthew")]
[Author("Bob")]
public void SomeTest()
{
// test logic
}
Usage: Methods, Classes
Multiple: Yes
This allows you to specify the categories for a test or fixture. This is useful for specifying what type of logic your test might be being run against. Categories can later be included/excluded whne running tests.
[Test]
[Author("UI")]
[Category("Achievements")]
public void SomeTest()
{
// test logic
}
Usage: Methods, Classes
Multiple: No
Using this attribute allows you to specify the concurrency of a test or a fixture. If the attribute is omitted from a fixture then the default concurrency is Parallel. Conversely if it's omitted from a test, then the default concurrency is the concurrency of its parent fixture.
The parallel concurrency only works if your specify a test/fixture thread count greater than 1 (explanded in Console and GUI sections).
[Test]
[Concurrency(ConcurrencyType.Parallel)]
public void SomeTest()
{
// test logic
}
Usage: Method, Classes
Multiple: No
Using this attribute allows you to specify a short description as to what your test or fixture is doing.
[Test]
[Description("This does something, I don't know what, just something.")]
public void SomeTest()
{
// test logic
}
Usage: Methods
Multiple: No
This attribute allows you to sepcify an expected exception that your test may throw while running. If the exception thrown matches the expected one then the test passes.
Furthermore, you can also specify what the expected exception message will be, and if the message check should be exact, contains or regex. You can even state that you want the check to be inversed, so an inverse exact match would be any exception of the expected type that is not this message.
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "This thing was null!", MatchType = MatchType.Exact)]
public void SomeTest()
{
// test logic
}
Usage: Methods, Classes
Multiple: No
This attribute allows you to specify whether a test or fixture should be ignored. An ignored test or fixture will not be run when running tests. You are also able to specify a reason as to why the test or fixture is ignored.
[Test]
[Ignore(Reason = "Ignored because it was exposing a bug. Mwuhahah.")]
public void SomeTest()
{
// test logic
}
Usage: Methods
Multiple: No
Using this attribute allows you to run a test multiple times in parallel.
[Test]
[ParallelRepeat(3)]
public void SomeTest()
{
// this test logic will be repeated 3 times in parallel
}
Usage: Methods
Multiple: Yes
This attribute allows you to specify mutliple test cases that your test should be run using, except it will run them all in parallel. You specify the parameters for the test within the attribute, and Edison will inject them into your test. The parameters for a test case must be constant values.
[Test]
[ParallelTestCase("String", 101, false)]
[ParallelTestCase("Gnirts", 102, true)]
public void SomeTest(string str, int value, bool flag)
{
// this test logic will be run twice in parallel, using the different
// parameters in the test cases
}
Usage: Methods, Classes
Multiple: No
Using this attribute allows you to run a test, or a fixture, multiple times.
[Test]
[Repeat(3)]
public void SomeTest()
{
// this test logic will be repeated 3 times
}
Usage: Classes
Multiple: No
This attribute allows you to specify a class, that contains a setup and teardown process, which should be run before all fixtures and after all fixtures. So this could be for initial setup from configuration files, or for final teardown of a database once everything has completed.
[SetupFixture]
public class GlobalSetupFixture
{
[Setup]
public void Setup()
{
// setup logic
}
[Teardown]
public void Teardown()
{
// teardown logic
}
}
Usages: Methods Multiple: No
This attribute allows you to specify a channel, or user, in Slack to which Edison should send the result of specific tests. Only tests with this attribute will be posted to Slack, and eyou can also filter which result types should be sent: Success only, Failures only (default), or Any.
[Test]
[Slack("SomeChannel", SlackTestResult = SlackTestResultType.Any)]
public class SomeTest()
{
// Test logic
}
Usages: Classes
Multiple: Yes
Using this attribute is a little similar to using a Category attribute. The only difference is that it can only be applied to classes, and not methods.
Suites can be used to specify what fixtures and tests can be run by which people, or in which environment. For example if you only want developers to run certain tests, or you only want your regression environment to run certain tests, then you can specify what fixtures are for which suites. A suite can then be passed in on the command line, or using the GUI.
[TestFixture]
[Suite("Regression")]
[Suite("Developer")]
public class SomeFixture
{
// tests
}
Usage: Methods, Classes
Multiple: Yes
This attribute allows you to specify mutliple test cases that your test should be run using. You specify the parameters for the test within the attribute, and Edison will inject them into your test. The parameters for a test case must be constant values.
[Test]
[TestCase("String", 101, false)]
[TestCase("Gnirts", 102, true)]
public void SomeTest(string str, int value, bool flag)
{
// this test logic will be run twice, using the different
// parameters in the test cases
}
Usage: Methods, Classes
Multiple: No
This attribute allows you to specify the current version of a test. This could be an iteratable count of the number of times the test has been updated, or the ticket number that last caused the test to be updated.
The version of a test is later accessible via the TestResult object during a Teardown.
[Test]
[Version("v1.0.0")]
public void SomeTest()
{
// test logic
}