This post shows you how to Unit and integration test your Data layer, service layer and view layer in a Spring 4 MVC + Hibernate 4 + MySQL + Maven integration application. This post is continuation of Previous post. In this post we will learn how to add unit and integration test in SpringMVC and…
Continue readingAuthor: websystiqueadmin
TestNG Mockito Example Stubbing Void Methods
In this post we will learn about using TestNG and Mockito together. We will also learn about stubbing void methods with Mockito. Mockito library enables mocks creation, verification and stubbing. In simple terms, mock objects comes handy in situations like when you are testing a class [A] which depends on another class [B]. To test…
Continue readingTestNG @DataProvider Example
In this post we will learn about TestNG @DataProvider annotation to parameterize your tests in order to write data-driven tests. In data-driven testing, we run the same tests multiple times but with different sets of data which we pass into test methods using parameters.Let’s get going. Let’s take a simple Calculator example: Above class have…
Continue readingTestNG @Parameters Example
In this post we will learn about how to parameterize your TestNG tests using TestNG @Parameters annotation which is used to pass simple primitive parameters from configuration file to test methods. These parameters are defined in suite [testng.xml] file. Let’s get going. In TestNG, there are primarily two popular ways to pass parameters to your…
Continue readingTestNG dependsOnGroups Example
In this post we will see TestNG groups dependency example showing a test depending on groups of tests methods using @Test annotation’s dependsOnGroups and alwaysRun attributes. Let’s get going. dependsOnGroups : dependsOnGroups attribute on a test method [test1 e.g.] specifies all the groups [group1, group2,..] this test method depends on. It means test1 will start…
Continue readingTestNG dependsOnMethods Example
In this post we will see TestNG dependency example between different test methods using @Test annotation’s dependsOnMethods and alwaysRun attributes. A very simple and real life use case [where these attributes can be handy] is user update operations e.g. In order to update a user, it must be created at first place. So while writing…
Continue readingTesNG expectedExceptions example
In this post we will learn how to use TestNG expectedExceptions feature to test the expected exception your code might throw in certain situations. We can annotate a test method with particular exception information using @Test(expectedExceptions = Exception.class) if we know that the method will throw this kind of exception during execution. Let’s get going….
Continue readingTestNG timeOut example
In this post we will learn how to configure TestNG Tests to timeout after certain time, using TestNG timeout feature with help of @Test(timeOut = 1000). A @Test is supposed to complete its execution within very short time. In case a @Test is taking unreasonably long-time than expected, it’s something to investigate. In those situations,…
Continue readingTestNG enabled example
In this post we will learn how to disable or ignore a test using @Test(enabled=false). Occasionally, we want to disable some tests because of some reasons(like a particular api being tested in those tests is changing but we don’t want to stop the complete CI build which apart from this API should be working fine)….
Continue readingMaven Surefire plugin & TestNG
In this post we will learn how to execute TestNG tests with Maven using maven-surefire-plugin. This post also goes over explaining TestNG XML configuration file (aka Suite, testng.xml) , it’s purpose, it’s content, it’s location in your project and how to use it for your tests [using Eclipse plugin or Maven]. Let’s begin. What is…
Continue reading