itemprop = "text">
I have a base class to generate duplicate test methods. Public Interface IService1 {} Public Interface IService2: IService1 {} [TestFixture] Public Essentials MyBase {Private Redoni IService1 Service; Secure MyBase (IService1 service) {this.service = service; } [Test] Public Zero test1 () {//service.callmethod}}
I have implemented this base class in another test class like this:
returns this error: No suitable constructor found .
[TestFixture] MyBase
, as an abstract class, it can not be made, so it is not really a stability.
NUnit knows only That's how to call the default constructor for your class, so your test fixtures should be the default constructor with your example code, you come from service
MyTest
constructor Are hoping to come in ?
An alternative approach that can be used to get to represent the creation of object classes of children from the same kind of thing that the original parent. So you end up with something like this:
Public abstract class MyBase {[Test] Public Zero test1 () {GetService (). Callmethod (); } Public abstract IService1 GetService (); } [TestFeacense] Public Class MyTest: MyBase (Private IISSE 2 Service; [Set Up] Public Zero Setup () {service = A.Fake & lt; IService2 & gt; ();} Public Override IService1 GetService () {Return Service ;}}
Then the child class allows the parent class to obtain the service object context requirement to implement the basic method GetService
. < / P>
No comments:
Post a Comment