Testing ability is a tool for identifying professional developers and amateur novices. It not only reflects whether it can follow TDD (Test-Driven Development), BDD (Behavior-Driven Development), or any other test method, but also whether you have written a tool that can automatically test software code. ability.
Today, many Java developers primarily write various units and integration test programs that will run automatically at build time, using continuous integration tools such as Jenkins or TeamCity.
If there are people around you who have questions about “why programmers should pay attention to automated testing,†then you can tell him that with the advent of DevOps and deeper understanding of it, the industry’s importance to automated testing is also exponential. In growth.
For the average company, programmers who are good at writing unit tests are usually more admired. Because they are familiar with a variety of unit testing framework libraries and tools, such as JUnit, Selenium, REST-Assured, Spock framework and so on.
As a Java developer, we often touch on quite different areas, such as writing core Java code, creating JSP pages, writing REST APIs, and sometimes even creating some Groovy scripts for automated builds. This is why we also need to understand how to use different tools for automated testing.
For example: If I only knew to use JUnit for a long time, but suddenly had to test the JSP page, I wouldn’t have any direction at all, and I wouldn’t expect to find a tool like Selenium. Also for REST Assured, since I usually use the curl command to test my own REST APIs, REST Assured brings the REST API unit tests to another level.
Ten Units and Integration Test Tools for Java Programmers
If a worker wants to do good, he must first sharpen his tools. I have always believed that this sentence is also applicable to programmers. Therefore, I often explore, try, learn and explore new tools and libraries in my spare time. Below I will list some of the tools I have collected.
The ten excellent basic tools, frameworks, and libraries mentioned in this article will help Java developers write a variety of units and integration tests based on the projects they are working on.
1.JUnitI don't think I need to make any introduction to JUnit. Even if you are a beginner in Java programming, you must have heard of its name. It allows you to write a corresponding unit test program for Java code.
Almost all mainstream integrated development environments (IDEs) such as Eclipse, NetBeans, and IntelliJ provide integration with JUnit, which means that you can write and run unit tests in these IDE environments.
Although JUnit 5 is now released, most people still use JUnit 4. However, this year may have the next version available. You can use JUnit for unit and integration testing, and it can also support the various features of Java 8.
Testing and validating various REST services in Java is much more difficult than a dynamic language such as Groovy.
REST Assured brings linguistic simplicity to the Java world. It is a very good REST API integration testing tool.
Selenium should be the most popular tool in Java UI testing. It allows you to test JSP pages without launching them in the browser.
You can use JUnit and Selenium to test your own Web application's UI. It even allows you to write Web applications to accept various tests.
TestNG is a testing framework developed by JUnit and NUnit, but it introduces many new features and is easier to use. For example: annotaTIons (see http://javarevisited.blogspot.hk/2012/06/junit4-annotaTIons-test-examples-and.html#axzz56lq0jrxn) allows you to run a variety of available strategies in any large thread pool Test (put all methods in their own thread, one for each test class).
By using the antonatens in JUnit 4, you can make up for the gap between JUnit and TestNG. In addition, as long as you like, you can also integrate the Hamcrest's matcher.
In Java's library, there are many mocking frameworks such as PowerMock and JMock. I personally like Mockito because it has a simple API, complete documentation and lots of examples.
Mocking is a key technology for unit testing today. It allows you to test your code independently without any dependencies. This is why I encourage every Java developer to master the mocking framework while learning Junit. s reason.
Although I pushed Mockito, this mocking framework. Of course, if you are interested, you can also try PowerMock or JMock.
6.Spock FrameworkSpock is another testing and specification framework for Java and Groovy applications. It was written by Groovy and therefore it is very expressive and it is an extremely regulated language.
By using Spock, your test program becomes more readable and easier to maintain. Thanks to Junit's running programs, Spock is compatible with most IDEs, build tools, and continuous integration type servers.
Unfortunately, I did not find any online learning courses on the Spock framework. Of course, you can use "Spock for Java Testing" (https://Java-TesTIng-Spock-Konstantinos-Kapelonis/dp/1617292532/ref=as_at?creativeASIN=1617292532&linkCode=w61&imprToken=MfCu8SgYHitGBTnYpPUhiw&slotNum=0&tag=javamysqlanta-20) Come as the first step to get started.
Cucumber is another common tool for automated integration testing. Its difference from other similar tools is its specification capability.
Cucumber merges specifications and test documents into a single unit that can be automatically tested by Cucumber, thus ensuring that your specification documents are always up-to-date.
Spring MVC is a very useful testing framework that allows deep testing without involving the Web container.
It is a very useful library for writing automated tests for Spring applications. If you want to perform unit and integration testing on Spring-based applications, including MVC controllers, it can provide first-class support.
There is also a Spring Test DbUnit that integrates the Spring Test framework with DbUnit and Spring Test MVC with HtmlUnit.
By using these tools, you can easily test various Spring MVC applications in an automated manner.
9.DBUnitIn general, databases are an integral part of many Java applications, including core Java and Web applications. Of course, it may also be the biggest obstacle in unit testing. Since anyone can change data, schemas, tables, or even stored procedures, integration testing on a Dev or UAT database is often unreliable and can easily lead to failure of automated integration testing.
DbUnit is an extension of JUnit that can be used to initialize the database to a known state before each integration test to ensure that the database contains the correct data.
Although DbUnit has its own problems, it can help us to separate the creation test data from the test code, so it is still a very useful tool.
Robot Framework is a generic Python-based test automation framework that can be used for acceptance testing and test-driven development.
It is a keyword-driven test framework that uses tabular test data as a grammar. You can use it to test distributed heterogeneous applications, where the verification part needs to involve multiple technologies and interfaces.
If you want to learn about this integration testing framework, you can use the Robot Framework test automation on Udemy website as a good start (https://siteID=JVFxdTr9V80-V8cQwgaw3imzy3q58cwXSQ&LSNPUBID=JVFxdTr9V80). This is a two-part course covering the basic and advanced features of the Robot framework.
The above is a basic unit and integration testing tool and framework library for Java developers.
Of course there are some libraries that I haven't yet listed, such as AssertJ and Hamcrest. As long as you are willing to take the time to research, they can help you write perfect and smooth test code.
Media Converter And Optical Fiber Switch
Media Converter Optical Fiber Switch fiber optic switcher
Media Converter,Optical Fiber Switch,Fiber Optic Switcher
Chinasky Electronics Co., Ltd. , https://www.cctv-products.com