SlideShare ist ein Scribd-Unternehmen logo
1 von 9
JUnit Testing Frameworks
for Developers
Srini Seetharaman
srini@sdnhub.org
March 2015
Goals
► OpenDaylight’s Integration project looks at the overall system
test, in some ways treating the controller like a blackbox
► Developers write white-box test cases that enable different
types of test and verification that will tie up with Jenkins
2
JUnit
► JUnit is the most common testing framework used
► Can cover logic within a single bundle, or multiple bundles
 Integrated with Maven through multiple plugins
 Other mock framework (e.g., Mockito and EasyMock) make testing even
easier with creating mock objects pre-programmed with expectation
3
JUnit Basic Annotations
Annotation Description
@Test
public void method()
The @Test annotation identifies a method as a test method.
@Test (expected = Exception.class) Fails if the method does not throw the named exception.
@Test(timeout=100) Fails if the method takes longer than 100 milliseconds.
@Before
public void method()
This method is executed before each test. It is used to prepare the test
environment (e.g., read input data, initialize the class).
@After
public void method()
This method is executed after each test. It is used to cleanup the test
environment (e.g., delete temporary data, restore defaults).
@BeforeClass
public static void method()
This static method is executed once, before the start of all tests. It is used to
perform time intensive activities, for example, to connect to a database.
@AfterClass
public static void method()
This static method is executed once, after all tests have been finished. It is used
to perform clean-up activities, for example, to disconnect from a database.
@Ignore Ignores the test method. This is useful when the underlying code has been
changed and the test case has not yet been adapted. Or if the execution time of
this test is too long to be included.
4
Three Maven Testing Plugins
1. Unit tests with SureFire plugin
 To verify if a certain feature is available
 If test fails, build breaks right away
 One maven goal:
► surefire:test
2. Integration tests with Fail-safe plugin
 Test multiple components
 Includes files with name IT*.java, *IT.java, *ITCase.java
 If test fails, cleans up state in a post-integration-test phase, but does not fail the build
 Two maven goals
► failsafe:integration-test runs the integration tests of an application
► failsafe:verify verifies that the integration tests of an application passed.
3. Integration tests with Pax-Exam plugin
 Tests cross-bundle interfaces and integrates with OSGi
 Can be used for spinning up virtual bundle container
5
JUnit Extended with Pax-Exam
► Spins up a test container with all dependencies injected
► Pax Exam JUnit test requires a method annotated with @Configuration
6
@RunWith(PaxExam.class)
public class SampleTest {
@Inject
private HelloService helloService;
@Configuration
public Option[] config() {
return options(
mavenBundle("com.example.myproject", "myproject-api", "1.0.0-SNAPSHOT"),
bundle("http://www.example.com/repository/foo-1.2.3.jar"),
junitBundles()
);
}
@Test
public void getHelloService() {
assertNotNull(helloService);
assertEquals("Hello Pax!", helloService.getMessage());
}
}
JUnit with Mockito
► In some cases, you don’t need to create a real object to test code.
► Using Mock objects Minimizes number of moving pieces tested
7
@RunWith(MockitoJUnitRunner.class)
public class MockitoTest {
// assume there is a class MyDatabase
@Mock
MyDatabase databaseMock;
@Test
public void testQuery() {
// assume there is a class called ClassToTest
// which could be tested
ClassToTest t = new ClassToTest(databaseMock);
// call a method
boolean check = t.query("* from t");
// test the return type
assertTrue(check);
// test that the query() method on the
// mock object was called
Mockito.verify(databaseMock).query("* from t");
}
}
A more Concrete ODL example:
controller/sample/l2switch/md/topology/TopologyLinkDataChangeHandlerTest
8
public class TopologyLinkDataChangeHandlerTest {
NetworkGraphService networkGraphService;
DataBrokerService dataBrokerService;
DataChangeEvent dataChangeEvent;
Topology topology;
Link link;
@Before
public void init() {
networkGraphService = mock(NetworkGraphService.class);
dataBrokerService = mock(DataBrokerService.class);
dataChangeEvent = mock(DataChangeEvent.class);
link = mock(Link.class);
topology = mock(Topology.class);
}
@Test
public void testOnDataChange() throws Exception {
TopologyLinkDataChangeHandler topologyLinkDataChangeHandler = new
TopologyLinkDataChangeHandler(dataBrokerService, networkGraphService, 2);
Map<InstanceIdentifier<?>, DataObject> original = new HashMap<InstanceIdentifier<?>, DataObject>();
when(dataChangeEvent.getOriginalOperationalData()).thenReturn(original);
InstanceIdentifier<?> instanceIdentifier = InstanceIdentifierUtils.generateTopologyInstanceIdentifier("flow:1");
Map<InstanceIdentifier<?>, DataObject> updated = new HashMap<InstanceIdentifier<?>, DataObject>();
DataObject dataObject = mock(DataObject.class);
updated.put(instanceIdentifier, dataObject);
when(dataChangeEvent.getUpdatedOperationalData()).thenReturn(updated);
when(dataBrokerService.readOperationalData(instanceIdentifier)).thenReturn(topology);
List<Link> links = new ArrayList<>();
links.add(link);
when(topology.getLink()).thenReturn(links);
topologyLinkDataChangeHandler.onDataChanged(dataChangeEvent);
Thread.sleep(2100);
verify(networkGraphService, times(1)).addLinks(links);
}
Setup data
Setup mock objects
Exercise
Verify
Sonar Code Coverage
► Sonar picks up testing results by using the JaCoCo plugin
► http://sonar.opendaylight.org/dashboard/index/45745?metric=it_coverage
9

Weitere ähnliche Inhalte

Was ist angesagt?

TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
Denis Bazhin
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
Renato Primavera
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
Will Shen
 

Was ist angesagt? (20)

Test ng
Test ngTest ng
Test ng
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next Generation
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
 
Test ng for testers
Test ng for testersTest ng for testers
Test ng for testers
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the war
 
TestNG with selenium
TestNG with seleniumTestNG with selenium
TestNG with selenium
 
Bug zillatestopiajenkins
Bug zillatestopiajenkinsBug zillatestopiajenkins
Bug zillatestopiajenkins
 
X unit testing framework with c# and vs code
X unit testing framework with c# and vs codeX unit testing framework with c# and vs code
X unit testing framework with c# and vs code
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 
JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeJUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
 
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
 
NUnit Features Presentation
NUnit Features PresentationNUnit Features Presentation
NUnit Features Presentation
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy Code
 

Ähnlich wie Introduction to JUnit testing in OpenDaylight

J unit presentation
J unit presentationJ unit presentation
J unit presentation
Priya Sharma
 

Ähnlich wie Introduction to JUnit testing in OpenDaylight (20)

Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDD
 
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
 
3 j unit
3 j unit3 j unit
3 j unit
 
Test ng tutorial
Test ng tutorialTest ng tutorial
Test ng tutorial
 
L08 Unit Testing
L08 Unit TestingL08 Unit Testing
L08 Unit Testing
 
Junit With Eclipse
Junit With EclipseJunit With Eclipse
Junit With Eclipse
 
ikp321-04
ikp321-04ikp321-04
ikp321-04
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TestNG
TestNGTestNG
TestNG
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
 
JMockit
JMockitJMockit
JMockit
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Unit test
Unit testUnit test
Unit test
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 

Mehr von OpenDaylight

Mehr von OpenDaylight (7)

OpenDaylight OpenFlow clustering
OpenDaylight OpenFlow clusteringOpenDaylight OpenFlow clustering
OpenDaylight OpenFlow clustering
 
Network Intent Composition in OpenDaylight
Network Intent Composition in OpenDaylightNetwork Intent Composition in OpenDaylight
Network Intent Composition in OpenDaylight
 
OpenDaylight MD-SAL Clustering Explained
OpenDaylight MD-SAL Clustering ExplainedOpenDaylight MD-SAL Clustering Explained
OpenDaylight MD-SAL Clustering Explained
 
ONOS Platform Architecture
ONOS Platform ArchitectureONOS Platform Architecture
ONOS Platform Architecture
 
Security of OpenDaylight platform
Security of OpenDaylight platformSecurity of OpenDaylight platform
Security of OpenDaylight platform
 
Using OVSDB and OpenFlow southbound plugins
Using OVSDB and OpenFlow southbound pluginsUsing OVSDB and OpenFlow southbound plugins
Using OVSDB and OpenFlow southbound plugins
 
Yang in ODL by Jan Medved
Yang in ODL by Jan MedvedYang in ODL by Jan Medved
Yang in ODL by Jan Medved
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Introduction to JUnit testing in OpenDaylight

  • 1. JUnit Testing Frameworks for Developers Srini Seetharaman srini@sdnhub.org March 2015
  • 2. Goals ► OpenDaylight’s Integration project looks at the overall system test, in some ways treating the controller like a blackbox ► Developers write white-box test cases that enable different types of test and verification that will tie up with Jenkins 2
  • 3. JUnit ► JUnit is the most common testing framework used ► Can cover logic within a single bundle, or multiple bundles  Integrated with Maven through multiple plugins  Other mock framework (e.g., Mockito and EasyMock) make testing even easier with creating mock objects pre-programmed with expectation 3
  • 4. JUnit Basic Annotations Annotation Description @Test public void method() The @Test annotation identifies a method as a test method. @Test (expected = Exception.class) Fails if the method does not throw the named exception. @Test(timeout=100) Fails if the method takes longer than 100 milliseconds. @Before public void method() This method is executed before each test. It is used to prepare the test environment (e.g., read input data, initialize the class). @After public void method() This method is executed after each test. It is used to cleanup the test environment (e.g., delete temporary data, restore defaults). @BeforeClass public static void method() This static method is executed once, before the start of all tests. It is used to perform time intensive activities, for example, to connect to a database. @AfterClass public static void method() This static method is executed once, after all tests have been finished. It is used to perform clean-up activities, for example, to disconnect from a database. @Ignore Ignores the test method. This is useful when the underlying code has been changed and the test case has not yet been adapted. Or if the execution time of this test is too long to be included. 4
  • 5. Three Maven Testing Plugins 1. Unit tests with SureFire plugin  To verify if a certain feature is available  If test fails, build breaks right away  One maven goal: ► surefire:test 2. Integration tests with Fail-safe plugin  Test multiple components  Includes files with name IT*.java, *IT.java, *ITCase.java  If test fails, cleans up state in a post-integration-test phase, but does not fail the build  Two maven goals ► failsafe:integration-test runs the integration tests of an application ► failsafe:verify verifies that the integration tests of an application passed. 3. Integration tests with Pax-Exam plugin  Tests cross-bundle interfaces and integrates with OSGi  Can be used for spinning up virtual bundle container 5
  • 6. JUnit Extended with Pax-Exam ► Spins up a test container with all dependencies injected ► Pax Exam JUnit test requires a method annotated with @Configuration 6 @RunWith(PaxExam.class) public class SampleTest { @Inject private HelloService helloService; @Configuration public Option[] config() { return options( mavenBundle("com.example.myproject", "myproject-api", "1.0.0-SNAPSHOT"), bundle("http://www.example.com/repository/foo-1.2.3.jar"), junitBundles() ); } @Test public void getHelloService() { assertNotNull(helloService); assertEquals("Hello Pax!", helloService.getMessage()); } }
  • 7. JUnit with Mockito ► In some cases, you don’t need to create a real object to test code. ► Using Mock objects Minimizes number of moving pieces tested 7 @RunWith(MockitoJUnitRunner.class) public class MockitoTest { // assume there is a class MyDatabase @Mock MyDatabase databaseMock; @Test public void testQuery() { // assume there is a class called ClassToTest // which could be tested ClassToTest t = new ClassToTest(databaseMock); // call a method boolean check = t.query("* from t"); // test the return type assertTrue(check); // test that the query() method on the // mock object was called Mockito.verify(databaseMock).query("* from t"); } }
  • 8. A more Concrete ODL example: controller/sample/l2switch/md/topology/TopologyLinkDataChangeHandlerTest 8 public class TopologyLinkDataChangeHandlerTest { NetworkGraphService networkGraphService; DataBrokerService dataBrokerService; DataChangeEvent dataChangeEvent; Topology topology; Link link; @Before public void init() { networkGraphService = mock(NetworkGraphService.class); dataBrokerService = mock(DataBrokerService.class); dataChangeEvent = mock(DataChangeEvent.class); link = mock(Link.class); topology = mock(Topology.class); } @Test public void testOnDataChange() throws Exception { TopologyLinkDataChangeHandler topologyLinkDataChangeHandler = new TopologyLinkDataChangeHandler(dataBrokerService, networkGraphService, 2); Map<InstanceIdentifier<?>, DataObject> original = new HashMap<InstanceIdentifier<?>, DataObject>(); when(dataChangeEvent.getOriginalOperationalData()).thenReturn(original); InstanceIdentifier<?> instanceIdentifier = InstanceIdentifierUtils.generateTopologyInstanceIdentifier("flow:1"); Map<InstanceIdentifier<?>, DataObject> updated = new HashMap<InstanceIdentifier<?>, DataObject>(); DataObject dataObject = mock(DataObject.class); updated.put(instanceIdentifier, dataObject); when(dataChangeEvent.getUpdatedOperationalData()).thenReturn(updated); when(dataBrokerService.readOperationalData(instanceIdentifier)).thenReturn(topology); List<Link> links = new ArrayList<>(); links.add(link); when(topology.getLink()).thenReturn(links); topologyLinkDataChangeHandler.onDataChanged(dataChangeEvent); Thread.sleep(2100); verify(networkGraphService, times(1)).addLinks(links); } Setup data Setup mock objects Exercise Verify
  • 9. Sonar Code Coverage ► Sonar picks up testing results by using the JaCoCo plugin ► http://sonar.opendaylight.org/dashboard/index/45745?metric=it_coverage 9