vrakeshreddy / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Multiple Impersonations on a TestCase #558

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Write a test case
2. add the  [Impersonate] attribute
3. add it again

What is the expected output? What do you see instead?
It is probably by design that duplicate impersonation attributes are not
allowed?
But a mechanism to run a test case using a series of users would be nice
and useful (i.e. test a system using all available users)
Suggestion 1: allow multiple impersonate attributes
Suggestion 2: allow specifying a role, and impersonate using all users in a
role (if possible)
Suggestion 3: enable some Factory mechanism.

What version of the product are you using? On what operating system?
3.1

Please provide any additional information below.

Original issue reported on code.google.com by niklas.d...@gmail.com on 9 Oct 2009 at 6:42

GoogleCodeExporter commented 9 years ago
Interesting idea.

I'm starting to think that we might want to reexamine how some of these 
decorators
hook up to the tests.

* ExpectedExceptionAttribute works by setting some custom metadata that the test
executor knows about.  The same metadata can be specified in other ways such as 
in
CSV files for data-driven tests.  This kind of metadata-driven test semantic is
unique to expected exceptions so we don't support it for impersonation or other 
things.

* ImpersonateAttribute just wraps the test execution with an impersonation 
context.

* BrowserAttribute (in the new MbUnit samples for WatiN) actually does support
multiple instances by making the test data driven.  It injects a new test 
parameter
and binds a data source that provides browser configuration options derived 
from the
attribute properties.  This way the test runs multiple times with different
configurations.

* TestCases produced by test factories have none of these capabilities.  It is 
not
possible to apply impersonation to a test case.  It would be nice if we split up
decorators into two parts: the attribute and the logic.  That way the logic 
could
perhaps be reused elsewhere.

It seems to me like there ought to be a nice way to unify these mechanisms.

Any ideas?

Original comment by jeff.br...@gmail.com on 9 Oct 2009 at 8:37

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 17 Jul 2010 at 8:08

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 27 Oct 2010 at 8:54

GoogleCodeExporter commented 9 years ago
Done (v3.3 trunk)

It's now possible to write the following:

[TestFixture]
public class MyTestFixture
{
  [Test]
  [Impersonate(UserName = "Julius Caesar", Password = "VeniVidiVici")]
  [Impersonate(UserName = "Marcus Brutus", Password = "EtTuBrute?")]
  public void MyTest()
  {
    // Some test logic here...
  }
}

Original comment by Yann.Tre...@gmail.com on 27 Oct 2010 at 9:09

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 10 Feb 2011 at 11:28