NUnit and BOs


Author
Message
Scott
Scott
StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)StrataFrame User (200 reputation)
Group: Forum Members
Posts: 176, Visits: 1.5K
Anyone using NUnit with StrataFrame?

Any suggestion on how to test BOs?

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Nope, we're using Visual Studio TS for Software Developers, which has the VSTS unit testing. Most of our unit tests are very straightforward... pull in a record -> check the count -> pull in another record -> check the count -> modify a record -> check IsDirty -> Save() the BO -> check IsDirty again... nothing too spectacular. All of them have been written by hand, rather than autogenerated.
Jason Seidell
Jason Seidell
StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)StrataFrame Novice (105 reputation)
Group: Forum Members
Posts: 59, Visits: 180
I got NUnit working fine with SF, however it requires a little more work to properly create the SF environment. From what I can gather NUnit does not run the code the same way as running the executable, so it needs some initialization or you will get DataSourceKey not found or problems loading and referencing SF BOs.



1) In the AppMain you need to add a new Main startup routine, I called mine TestingMain and have it at least call the SetDataSources() routine



** In AppMain ***

Public Shared Sub TestingMain()

SetDataSources()

End Sub

**************



2) Add a call to the initialization inside the NUnit startup routine.



** In the NUnit Test Fixture **

_

Public Sub InitEmployees()



' Initialize all the SF stuff

AppMain.TestingMain()



_employeesBO = New Employee_BO()

_ruleSetBO = New RuleSet_BO()



_employeesBO.FillAll()

_ruleSetBO.FillAll()





End Sub



_

Public Sub AddHours()

Dim results As New Collection()





_employeesBO.MoveFirst()

' Store all the current hours

For i As Integer = 1 To _employeesBO.Count

'_employeesBO.MoveAbsolute(i)

*****************************************



I assume if you are using locatelization or RBS then you may need to add some additional calls to the TestingMain(). I even suspect you could create TestingSetDataSources() to have the code automatically connect to a testing database when running the tests.



I hope this is a help to someone.



Jason S.

Jason Seidell

Programmer/Analyst

Infinedi

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, you have to do that with VSTS unit tests, too.  There is a ClassInitialize() method in which you have to add the DataSourceItem to the DataSources collection. 

You just had to find that the hard way Smile

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search