Tampilkan postingan dengan label Testing. Tampilkan semua postingan
Tampilkan postingan dengan label Testing. Tampilkan semua postingan

Kamis, 18 November 2021

Top 5 Courses to learn Appium for Testing Android Apps in 2022- Best of Lot

Top 5 Courses to learn Appium for Testing Android Apps in 2022- Best of Lot

Hello guys, if you want to learn the Appium tool for automation testing and looking for the best online courses then you have come to the right place. In the past, I have shared the best courses to learn Selenium and Android application development and in this article, I am going to share the best Appium courses for both beginners and experienced developers. These courses have been created by experts and trusted by many developers around the world and you can join them too to learn Appium from scratch as well as to improve your Appium skills if you are already using it without in-depth knowledge.

Rabu, 28 Juli 2021

How to Create JUnit Tests in Eclipse and NetBeans IDE? Java Example

How to Create JUnit Tests in Eclipse and NetBeans IDE? Java Example

Writing JUnit tests for Java classes in Eclipse and Netbeans IDE is super easy, and I will show you that later in this JUnit tutorial. Before that, let’s revise what is a unit test and why should you write them. A unit test is to test a smaller unit of code, e.g. methods.  Writing a unit test to test the individual unit of code is one of the best development practices and helps to find bug earlier in the development cycle. Though there is another unit testing framework available in Java e.g. TestNG, JUnit has its own place among Java developers. IMHO code review and unit testing are two most important practices for improving code quality and should always be followed during software development.
Difference between Stub and Mock object in Java Unit testing - JUnit

Difference between Stub and Mock object in Java Unit testing - JUnit

JUnit is the most popular framework for unit testing Java code. Unit testing is used to test a single programming unit e.g. a class or a method, in-fact many Java developers write unit tests on a per-method basis. Stub and Mock objects are two concepts that help during unit testing, they are not real objects but act like real objects for unit testing purposes. By the way, If you are absolutely a beginner in Java Unit testing then you can see this post to learn how to create the JUnit test in Eclipse. Coming back to Stubs and Mocks, One reason for using Stub and Mock object is the dependency of one unit into another. Since in real-world, the most unit doesn't work in isolation, they use dependent class and object to complete there task.
How to disable JUnit Test - @Ignore annotation Example

How to disable JUnit Test - @Ignore annotation Example

If you are using JUnit 4, then you can use @Ignore annotation to disable a test case; what this means is that any method which is annotated by @Ignore, will not be executed by JUnit. Why would you want to disable a test? Well, It may be because that particular test is for functionality that is not yet implemented fully, and because of that your build is failing. Like that there could be some other scenarios where you would like to temporarily disable a test or a group of tests. From JUnit 4 onward test methods are annotated with @Test, so if they are also annotated with @Ignore will not be executed as tests.
How to compare two XML files in Java - XMLUnit Example

How to compare two XML files in Java - XMLUnit Example

The XMLUnit library can be used to compare two XML files in Java. Similar to JUnit, XMLUnit can also be used to test XML files for comparison by extending the XMLTestcase class. It is a rich library and provides a detailed comparison of XML files. Btw, comparing XML is completely different than comparing String in Java or comparing objects using equals(), as two XML which contains different comments and whitespace can be equals, which is not true for String or character comparison. Also while comparing XML files, it's very important to know exactly which content or part is different and XMLUnit not only shows the content which is different but also the XPath of elements which is getting compared.

Selasa, 27 Juli 2021

How to test Exception thrown by a Java Method in JUnit? Example

How to test Exception thrown by a Java Method in JUnit? Example

One part of unit testing a Java method is checking exceptions thrown by that method. A Java unit test should verify the correct exception thrown in the exceptional case and no exception should be thrown in a normal case. In JUnit 3.XX, there was no direct support to pass or fail a test based upon the exception thrown by a Java method. JUnit4 address this issue and provides an easy, and readable way to test exceptions thrown by a Java method. There are many situations when you need to test the exception thrown by any method in Java. A classical example of this is testing API methods which should throw IllegalArgumentException if arguments passed to the method are not matching to pre-conditions.
Top 10 JUnit Best Practices for Java Developers

Top 10 JUnit Best Practices for Java Developers

JUnit best practices in Java
No doubt writing good JUnit test cases is a rare skill just like writing good Code. A good, well thought and well-written JUnit test can prevent several production issues during initial development or later maintenance in Java applications. Though one can only be perfect in writing the JUnit test by practice and a level of business knowledge which is important to envision different scenarios on which a method gets called, some best practices or experience of another developer may help to guide other programs. In this Java article, I am sharing some JUnit tips and JUnit best practices that I have learned and follow while writing unit tests using JUnit for Java programs.

Senin, 26 Juli 2021

JUnit4 Annotations : Test Examples and Tutorial

JUnit4 Annotations : Test Examples and Tutorial

JUnit4 Annotations are a single big change from JUnit 3 to JUnit 4 which is introduced in Java 5. With annotations creating and running a JUnit test becomes easier and more readable, but you can only take full advantage of JUnit4 if you know the correct meaning of annotations used on this version and how to use them while writing tests. In this
Junit tutorial we will not only understand the meaning of those annotations but also we will see examples of JUnit4 annotations. By the way, this is my first post in unit testing but if you are new here than you may like post 10 tips to write better code comments and 10 Object-oriented design principles for Programmer as well.
JUnit Testing Tips - Constructor is Called Before Executing Test Methods? Example

JUnit Testing Tips - Constructor is Called Before Executing Test Methods? Example

Even though almost all Java programmers either use JUnit or TestNG for their unit testing need along with some mock object generation libraries e.g. Mockito, but not everyone spends time and effort to learn subtle details of these testing libraries, at least not in proportion to any popular framework like Spring or Hibernate. In this blog post, I am sharing one of such detail, which has puzzled me a couple of years ago. At that time, though I had been using JUnit for a significant time, I wasn't aware that code written inside the constructor of the Test class is executed before each test method.

Kamis, 02 April 2020

Top 5 Books to Learn Unit testing, JUnit and TDD in Java - Best of Lot

Top 5 Books to Learn Unit testing, JUnit and TDD in Java - Best of Lot

Hello guys, If you done some professional Java development then you know that Unit testing is a very, very important thing to learn to adapt. I would say this is the single most practice in my book, which differentiates an excellent programmer with a professional programmer. It's one way you can see how disciplined a programmer is? It's also the best way to write clean code; a code that can stand the test of time, a code that is flexible enough to accommodate future changes and a code that you don't afraid of while changing. Despite several efforts of promoting unit testing by programming community and emphasizing unit testing by many notable programmers, it's still one of the lacking practice.