java 面向过程框架_这些是面向Java开发人员的顶级测试工具,库和框架

java 面向过程框架

by javinpaul

由javinpaul

这些是面向Java开发人员的顶级测试工具,库和框架 (These are the top testing tools, libraries and frameworks for Java developers)

概述了10种出色的测试框架,工具和库,它们可以提高您的自动化测试技能。 (An overview of 10 great testing frameworks, tools, and libraries to boost your Automation Testing skills.)

Recently, I have written some articles about what Java developers should learn this year, e.g. programming languages, libraries, and frameworks, but if you have just one thing to improve or learn, then that must be your automation testing skills.

最近,我写了一些有关Java开发人员今年应学习的知识的文章,例如编程语言框架 ,但是如果您仅需改进或学习一件事,那么这一定是您的自动化测试技能

Testing is one of the disciplines that separates professional developers from amateur ones. It’s not about following TDD, BDD, or whatever testing methodologies, but at the very minimum level, you must write code to test your code automatically.

测试是将专业开发人员与业余开发人员区分开的学科之一。 这与遵循TDD,BDD或任何测试方法无关,而是在最低限度上,您必须编写代码以自动测试代码。

Many Java developers write unit tests and integration tests that automatically run during build time, mostly by using continuous integration tools like Jenkins or TeamCity.

许多Java开发人员编写的单元测试和集成测试会在构建期间自动运行,主要是通过使用诸如Jenkins或TeamCity之类的持续集成工具。

If some of you are wondering why a programmer should focus on automation testing, then let me tell you that the importance of automation testing is growing exponentially due to more awareness and emergence of DevOps.

如果你们中的某些人想知道为什么程序员应该专注于自动化测试,那么让我告诉您,由于对DevOps的更多了解和出现,自动化测试的重要性正呈指数级增长。

Companies generally prefer programmers who are good at writing unit tests and show good knowledge of various unit testing frameworks, libraries, and tools e.g. JUnit, Selenium, REST-Assured, Spock framework, etc.

公司通常更喜欢擅长编写单元测试并且对各种单元测试框架,库和工具(例如JUnitSelenium ,REST-Assured, Spock框架等)具有丰富知识的程序员。

As a Java developer, we work on very different areas, starts from writing core Java code to creating JSP pages, writing REST APIs, and sometimes even creating Groovy scripts for build automation. That’s why we also need to be aware of the different tools we can use to automate testing.

作为Java开发人员,我们在非常不同的领域工作,从编写核心Java代码到创建JSP页面,编写REST API ,有时甚至创建用于构建自动化的Groovy脚本。 这就是为什么我们还需要了解可用于自动化测试的不同工具的原因。

For example, I only knew JUnit for a long time, but when I had to test my JSP pages, I was clueless until I found Selenium. Same goes with REST Assured because I usually test my REST API using curl commands, but REST Assured takes the unit testing of REST APIs to another level.

例如,我很长一段时间才了解JUnit,但是当我不得不测试JSP页面时,直到发现Selenium为止我一无所知。 REST Assured也是如此,因为我通常使用curl命令测试我的REST API,但是REST Assured将REST API的单元测试提高到另一个层次。

适用于Java程序员的10个有用的单元和集成测试工具 (10 Useful Unit and Integration Testing tools for Java Programmers)

Since I believe a programmer is as good as their tools, I always try to learn and explore new tools and libraries in my free time, and this list is part of that research.

因为我相信程序员和他们的工具一样好,所以我总是在业余时间尝试学习和探索新的工具和库,并且这份清单是该研究的一部分。

In this article, I am going to share 10 of the best and essential tools, frameworks, and libraries that can help Java developers writing unit tests and integration tests on their various Java projects.

在本文中,我将分享10个最佳和必要的工具框架和库,这些工具框架和库可以帮助Java开发人员在其各种Java项目上编写单元测试和集成测试。

1. JUnit (1. JUnit)

I don’t think JUnit needs any introduction. Even if you are a beginner Java programmer, you might have heard about it. It allows you to write unit tests for your Java code.

我认为JUnit不需要任何介绍。 即使您是Java初学者,也可能听说过它。 它允许您为Java代码编写单元测试。

Almost all major IDEs, e.g. Eclipse, NetBeans, and IntelliJIDEA, provide JUnit integrations, which means you can both write and run the unit test right from those IDEs.

几乎所有主要的IDE(例如EclipseNetBeansIntelliJIDEA )都提供JUnit集成,这意味着您可以直接从这些IDE编写和运行单元测试。

Most of us are still using JUnit 4, but JUnit 5 is already released and probably the next thing to look at this year. You can use JUnit for both unit and integration testing and it also supports Java 8 features.

我们大多数人仍在使用JUnit 4,但JUnit 5已经发布,可能是今年要讨论的下一件事情。 您可以将JUnit用于单元测试和集成测试,它还支持Java 8功能。

Btw, if you are completely new in the unit testing world, particularly in Java unit testing, then this JUnit and Mockito crash course is a good starting point.

顺便说一句,如果您是单元测试领域的新手,尤其是在Java单元测试中,那么这个JUnit和Mockito速成课程 是一个很好的起点。

2. REST保证 (2. REST Assured)

Testing and validating REST services in Java is harder than in dynamic languages such as Groovy.

用Java测试和验证REST服务要比诸如Groovy这样的动态语言要难。

REST Assured brings the simplicity of using these languages into the Java domain. It’s a great tool for REST API integration tests.

REST Assured将使用这些语言的简单性带入Java域。 这是用于REST API集成测试的好工具。

If you want to learn more, you can also check REST API Testing Automation: via REST Assured & HTTP Client course.

如果您想了解更多信息,还可以通过REST保证和HTTP客户端课程查看REST API测试自动化

3.Selenium (3. Selenium)

Selenium is probably the most popular tool for Java UI testing, which allows you to test your JSP pages without launching them in a browser.

Selenium可能是Java UI测试中最受欢迎的工具,它使您可以测试JSP页面而无需在浏览器中启动它们。

You can test your web application UI using JUnit and Selenium. It even allows you to write web application acceptance tests.

您可以使用JUnit和Selenium测试Web应用程序UI。 它甚至允许您编写Web应用程序验收测试。

If you want to learn Selenium, Selenium WebDriver with Java — Basics to the Advanced course is the best place to start with.

如果您想学习Selenium,那么使用Java Selenium WebDriver-高级基础知识是最好的起点。

4. TestNG (4. TestNG)

TestNG is a testing framework inspired by JUnit and NUnit but introducing many new functionalities that make it more powerful and easier to use, such as annotations, running your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc).

TestNG是一个受JUnit和NUnit启发的测试框架,但是引入了许多使其更强大和易于使用的新功能,例如注释 ,在具有各种可用策略的任意大线程池中运行测试(所有方法都在各自线程中,每个测试类的线程数等)。

The gap between JUnit and TestNG has reduced because of using annotations from JUnit 4 and integrating the Hamcrest matchers as well but it’s up to you.

由于使用了JUnit 4中的注释并集成了Hamcrest匹配器,因此JUnit和TestNG之间的差距已经缩小,但这取决于您。

If you decide to learn TestNG for unit testing your Java code then TestNG Complete Bootcamp For Beginners — Novice To Ninja is a good course to start with.

如果您决定学习TestNG进行Java代码的单元测试,则可以使用TestNG初学者完整的Bootcamp-《 Ninja新手》是一个很好的入门课程。

5. Mockito (5. Mockito)

There are many mocking frameworks for Java classes, e.g. PowerMock and JMock, but I personally like Mockito for their simple API, great documentation, and lots of examples.

Java类有许多模拟框架,例如PowerMock和JMock,但我个人很喜欢Mockito,因为它们具有简单的API,出色的文档和大量示例。

Mocking is one of the essential techniques of modern-day unit testing, as it allows you to test your code in isolation without any dependencies, and that’s why I encourage every Java developer to learn a mocking framework along with JUnit.

模拟是现代单元测试的基本技术之一,因为它使您可以在没有任何依赖的情况下隔离地测试代码,这就是为什么我鼓励每个Java开发人员与JUnit一起学习模拟框架。

My favorite mocking framework is Mockito, but if you like, you can also explore PowerMock or JMock.

我最喜欢的模拟框架是Mockito,但如果愿意,还可以探索PowerMock或JMock。

If you also like Mockito and decide to learn this framework then Mockito Tutorial: Learn mocking with 25 Junit Examples is a good course to start with.

如果您也喜欢Mockito并决定学习此框架,那么Mockito教程:学习25 Junit示例的模拟是一个很好的入门课程。

6. Spock框架 (6. Spock Framework)

Spock is another testing and specification framework for Java and Groovy applications. It’s written in Groovy, which makes it a very expressive and to-the-point specification language.

Spock是另一个针对JavaGroovy应用程序的测试和规范框架。 它是用Groovy编写的,这使其成为一种非常具有表现力和针对性的规范语言。

When you use Spock, your test will become more readable and easier to maintain and thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers.

当您使用Spock时,您的测试将变得更具可读性,并且更易于维护,而且由于其JUnit运行程序,Spock与大多数IDE,构建工具和持续集成服务器兼容。

Unfortunately, I didn’t find a useful course to learn Spock framework but Java Testing with Spock book is a good resource to start with.

不幸的是,我没有找到学习Spock框架的有用课程,但是使用Spock进行Java测试是一门很好的资源。

7.Cucumber (7. Cucumber)

Cucumber is another great tool for automated integration tests, but what makes it different from other tools in the same category is its specification capability.

Cucumber是用于自动化集成测试的另一个出色工具,但是使其与同类产品中的其他工具不同的是它的规范功能。

Cucumber merges specification and test documentation into one cohesive whole living documentation and since they will be automatically tested by Cucumber, your specifications are always banged up-to-date.

Cucumber将规范和测试文档合并为一个完整的整体生活文档,并且由于Cucumber将自动对其进行测试,因此您的规范始终处于最新状态。

If you want to build a start to finish web automation testing framework and simulate user behavior on a web application then Selenium WebDriver with Java & Cucumber BDD is a good course to both learn and implement Cucumber in your project.

如果您想构建一个完整的Web自动化测试框架,并在Web应用程序上模拟用户行为,那么带有Java&Cucumber BDD的Selenium WebDriver是学习和实现项目中Cucumber的好课程。

8.弹簧测试 (8. Spring Test)

Spring MVC comes with a very useful test framework that allows doing in-depth testing without even involving a web container.

Spring MVC附带了一个非常有用的测试框架,该框架无需进行Web容器即可进行深入的测试。

It is one of the most useful libraries for writing automated tests to Spring applications. It provides first-class support for writing unit and integration tests to Spring-powered applications, including MVC controllers.

它是用于向Spring应用程序编写自动化测试的最有用的库之一。 它提供了一流的支持,可以为Spring供电的应用程序(包括MVC控制器)编写单元测试和集成测试。

There is also a Spring Test DbUnit that integrates the Spring Test framework with DbUnit and a Spring Test MVC HtmlUnit, which integrates the Spring Test MVC framework with HtmlUnit.

还有一个Spring Test DbUnit将Spring Test框架与DbUnit集成在一起,还有一个Spring Test MVC HtmlUnit,将Spring Test MVC框架与HtmlUnit集成起来。

By using these tools you can easily test your Spring MVC application in an automated way.

通过使用这些工具,您可以轻松地以自动化方式测试您的Spring MVC应用程序

If you want to learn more about how to test Spring applications, I suggest you take a look at the Testing Spring Boot: Beginner to Guru course by John S Thompson on Udemy.

如果您想了解有关如何测试Spring应用程序的更多信息,建议您看一下Udemy上的John S Thompson的“ 测试Spring Boot:初学者到大师”课程。

9. DBUnit (9. DBUnit)

A database is an integral part of many Java applications, both core Java and web applications, and probably the biggest obstacle while doing unit testing.

数据库是许多Java应用程序(包括核心Java和Web应用程序)不可或缺的部分,并且可能是进行单元测试时遇到的最大障碍。

It’s not reliable to connect to Dev or UAT databases for integration tests because anyone can change the data and schema, e.g. tables and stored procedures, and that will cause your automated integration tests to fail.

连接到Dev或UAT数据库进行集成测试并不可靠,因为任何人都可以更改数据和架构(例如表和存储过程) ,这将导致自动集成测试失败。

DbUnit is a JUnit extension that can be used to initialize the database into a known state before each integration test to ensure that the database contains the correct data.

DbUnit是JUnit扩展,可用于在每次集成测试之前将数据库初始化为已知状态,以确保数据库包含正确的数据。

DbUnit has its own issues, but it is a very useful tool because it helps us to separate the test data creation from the tested code.
DbUnit有其自身的问题,但是它是一个非常有用的工具,因为它可以帮助我们将测试数据的创建与测试的代码分开。
10.机器人框架 (10. Robot Framework)

The Robot Framework is a Python-based generic test automation framework for acceptance testing and acceptance test-driven development.

Robot Framework是基于Python的通用测试自动化框架,用于验收测试和验收测试驱动的开发。

It is a keyword-driven testing framework that uses tabular test data syntax. You can use it to test distributed, heterogeneous applications, where verification requires touching several technologies and interfaces.

它是一个使用表格式测试数据语法的关键字驱动的测试框架。 您可以使用它来测试分布式的异构应用程序,在该应用程序中,验证需要使用多种技术和界面。

If you decide to learn this wonderful framework for the integration test, then Udemy’s Robot Framework Test Automation is a great resource to start with.

如果您决定学习用于集成测试的出色框架,那么Udemy的机器人框架测试自动化 是一个很好的资源。

It’s a two-part course which covers the basic and advanced features of the Robot framework.

这是一个分为两部分的课程,涵盖了Robot框架的基本和高级功能。

结论 (Conclusion)

That’s all about some of the essential unit testing and integration testing tools, frameworks, and libraries for Java developers.

这就是针对Java开发人员的一些必不可少的单元测试和集成测试工具,框架以及库。

There are many more libraries that I have not included in this list, e.g. AssertJ and Hamcrest, which can help you to write beautiful and fluent tests — but take things slowly.

我还没有列出更多的库,例如AssertJ和Hamcrest,它们可以帮助您编写漂亮而流利的测试-但要慢慢进行。

To start with, learn a tool or library that you can use in your day-to-day work. For example, if you are working with Java UIs, then you should first learn Selenium because then you can focus on this tool more.

首先,学习可以在日常工作中使用的工具或库。 例如,如果您使用的是Java UI,则应该首先学习Selenium,因为这样您就可以更加专注于此工具。

Similarly, if you are working on REST APIs then learn REST Assured (See REST with Spring). If you are doing a lot of core Java work, then JUnit 5 is probably the first library you should look at.

同样,如果您正在使用REST API,请学习REST保证(请参阅REST with Spring )。 如果您正在做大量的Java核心工作,那么JUnit 5可能是您应该研究的第一个库。

Other Articles You May Like to Explore10 Things Java and Web Developer Should Learn in 201910 Testing Tools Java Developers Should Know5 Frameworks Java Developers Should Learn in 20195 Courses to Learn Big Data and Apache Spark in JavaFinally, Java has var to declare Local Variables10 Books Every Java Programmer Should Read10 Tools Java Developers uses in their day-to-day work10 Tips to become a better Java Developer

您可能想探索的其他文章 Java和Web开发人员在2019年应该学习的10件事Java开发人员应该在2019年学习的 10种测试工具Java开发 人员应该在2019年学习的5种框架 5个学习Java大数据和Apache Spark的课程 最后,Java需要声明var局部变量 每个Java程序员都应该阅读10本书 Java开发人员在日常工作中使用的10种工具 成为更好的Java开发人员的10条技巧

结束语 (Closing Notes)

Thanks, You made it to the end of the article … Good luck with your testing journey! It’s certainly not going to be easy, but by following this guide and framework, you are one step closer to becoming a professional programmer you always wanted to be.

谢谢,您已完成本文的结尾……祝您测试顺利! 当然,这并非易事,但是通过遵循本指南和框架,您将成为成为您一直希望成为的专业程序员的第一步。

If you like this article, then please share with your friends and colleagues, and don’t forget to follow javinpaul on Twitter!

如果您喜欢这篇文章,请与您的朋友和同事分享,不要忘记在Twitter上关注javinpaul

PS —如果您只是想从JUnit和Mockito开始,我认为JUnit和Mockito崩溃课程是最好的开始。 (P.S. — If you just want to start with JUnit and Mockito, I think the JUnit and Mockito crash course is the best one to start with.)

翻译自: https://www.freecodecamp.org/news/these-are-the-top-testing-tools-libraries-and-frameworks-for-java-developers-8c0e3f9bc11d/

java 面向过程框架

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值