OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule)
ABSTRACT
In order to meet software project requirements, it is important to implement ongoing quality assurance using automated tests. However, for OSGi platforms which are used in various areas such as Embedded or Enterprise this turns out to be difficult. If several components need to be tested together, unit tests written in Java tend to reach their limits. Thus, implementing these tests can be very time consuming. Using the Groovy language, OSGi integration tests are efficient and easy to write, e.g. registering Groovy mocks as a OSGi Service turns out to be very handy. Hereby declarative OSGi components can be tested, too. Even if an OSGi application has to be CDC-compliant, tests can be written using Groovy in a modern syntax.
This presentation demonstrates how to implement Groovy tests for a sample OSGi project and how Groovy tests can be executed in an Equinox OSGi environment. Furthermore, it shows how a continuous integration solution using Maven Tycho can look like.
SPEAKER BIOS
Lars Pfannenschmidt Interested in Mobile Applications, Smart Home, Domain Specific Languages, Machine Learning and agile development methodologies such as Scrum and Kanban. Senior Software Engineer and Founder of mobile.cologne
Dennis Nobel Dennis works as an IT Consultant for itemis in the field of Java, Web and Mobile Development. Moreover he is interested in Agile Development, Continuous Integration, Modeling Technologies, Testing, IoT, Smart Home, OSGi and Groovy.
9. Test Requirements
Easy to write
Modern language
Type-safe access to Java classes
Easy mocking
Executable in Eclipse and Maven CI build
Good IDE support
No side effects for production code
15. Groovy JUnit Test
Type inference, readable asserts, syntax sugar and more:
@et
Ts
vi 'ul pzawt BQsueol'){
od Bid iz ih B ac ny(
dfpza=Pzaule.ePza)
e iz
izBidrnwiz(
.ihac(B)
wtSueBQ
.ul(
bid)
asrTa pzasue i(B)
setht iz.ac, sBQ
}
26. Register OSGi service mocks (2)
@et
Ts
vi 'setta tehnlTascinmto i cle'){
od Asr ht h adernato ehd s ald(
..
.
rgseMc(amnSrie
eitrokpyetevc)
Pzaevc pzaevc =gtevc(izSrie
izSrie izSrie
eSriePzaevc)
dfpza=Pzaule.ePza)wtSueSueBQ.ul(
e iz
izBidrnwiz(.ihac(ac.B)bid)
dfcsoeIf =nwCsoeIf(MxMsemn" nwAdes) 44)
e utmrno
e utmrno"a utran, e drs(, 22
pzaevc.lcOdrnwOdrpza csoeIf)
izSriepaere(e re(iz, utmrno)
asrTa tascinald i(re
setht rnatoCle, stu)
}
27. OSGiTest.groovy
dfrgseeSrie =[]
e eitrdevcs
:
poetdasrc BnlCnetgtudeotx(
rtce btat udeotx eBnlCnet)
df<>Tgtevc(ls<>caz{
e T
eSrieCasT lz)
dfsrieeeec =bnlCnetgtevcRfrnecaznm)
e evcRfrne
udeotx.eSrieeeec(lz.ae
asrTa srieeeec,i(oNlVle)
setht evcRfrne sntulau()
bnlCnetgtevc(evcRfrne
udeotx.eSriesrieeeec)
}
dfrgseMc(e mc,Hstbepoete =[] {
e eitrokdf ok ahal rpris
:)
dfitraeae=mc.ls.nefcs.id{t).ae
e nefcNm
okcasitrae?fn(i}?nm
asrTa itraeae i(oNlVle)
setht nefcNm, sntulau()
rgseeSrie.u(nefcNm,
eitrdevcsptitraeae
bnlCnetrgseSrieitraeae mc,poete)
udeotx.eitrevc(nefcNm, ok rpris)
}
..
.
31. NOISULCNOC
Add integrative Tests to your OSGi projects
Easy to add groovy support in equinox and tycho
Groovy makes developing tests more easier
Powerful tests which run as fast as unit tests (>300 Tests in ~3
minutes)
Fun!
32. UOY KN HT
Checkout "groovy" OSGi testing at github:
$gtcoehts/gtu.o/roysitsiggt
i ln tp:/ihbcmgovog/etn.i
$c tsig
d etn
$mncenisal
v la ntl
Lars Pfannenschmidt (Intuit, Inc.)
Dennis Nobel (itemis AG)
1/32