netbeans7.4

代码生成的优点之一是能够查看如何使用特定的语言功能或框架。 正如我在《 NetBeans 7.2 beta:更快,更有用》一文中所讨论的那样, NetBeans 7.2 beta提供了TestNG集成 。 除了对该功能的单一引用之外,我在该帖子中没有进一步阐述,因为我想将这篇帖子专门用于该主题。 我使用这篇文章来演示如何使用NetBeans 7.2帮助刚接触TestNG的开发人员开始使用此替代(对JUnit )测试框架。

NetBeans 7.2的“新建文件”向导使创建空的TestNG测试用例更加容易。 以下屏幕快照展示了这一点,该屏幕快照是使用“新建文件” |“开始”按钮启动的。 单元测试(请注意,在“文件”下拉菜单下或通过在“项目”窗口中单击鼠标右键可以使用“新文件”)。

如上所示运行TestNG测试用例创建将导致以下生成的测试代码。

TestNGDemo.java(由NetBeans 7.2生成)

package dustin.examples;import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.Assert;/**** @author Dustin*/
public class TestNGDemo
{   public TestNGDemo(){}@BeforeClasspublic void setUpClass(){}@AfterClasspublic void tearDownClass(){}@BeforeMethodpublic void setUp(){}@AfterMethodpublic void tearDown(){}// TODO add test methods here.// The methods must be annotated with annotation @Test. For example://// @Test// public void hello() {}
}

NetBeans 7.2生成的测试包括注释,这些注释指示如何添加和注释测试方法(类似于现代版本的JUnit)。 生成的代码还显示了一些注释,这些注释用于总体测试用例的设置和拆卸以及针对每次测试的设置和拆卸(注释与JUnit相似)。 NetBeans标识此时尚未使用的import语句( import org.testng.annotations.Test;import org.testng.Assert; ),但是可能被使用,因此已包含在生成的代码中。

我可以轻松地将测试方法添加到此生成的测试用例中。 以下代码段是使用TestNG的测试方法。

testIntegerArithmeticMultiplyIntegers()

@Testpublic void testIntegerArithmeticMultiplyIntegers(){final IntegerArithmetic instance = new IntegerArithmetic();final int[] integers = {4, 5, 6};final int expectedProduct = 2 * 3 * 4 * 5 * 6;final int product = instance.multiplyIntegers(2, 3, integers);assertEquals(product, expectedProduct);}

当然,这看起来与我在测试Invalidgerquals with JUnit and Hamcrest和JUnit的内置Hamcrest Core Matcher Support文章中的插图所使用的IntegerArithmetic类所使用的同一个IntegerArithmetic类中使用的JUnit类似。 以下屏幕快照显示了通过右键单击测试用例类并选择“运行文件”(Shift + F6),在NetBeans 7.2 beta中的输出。

接下来,将复制NetBeans 7.2 beta中提供的TestNG运行的文本输出。

[TestNG] Running:Command line suite[VerboseTestNG] RUNNING: Suite: "Command line test" containing "1" Tests (config: null)
[VerboseTestNG] INVOKING CONFIGURATION: "Command line test" - @BeforeClass dustin.examples.TestNGDemo.setUpClass()
[VerboseTestNG] PASSED CONFIGURATION: "Command line test" - @BeforeClass dustin.examples.TestNGDemo.setUpClass() finished in 33 ms
[VerboseTestNG] INVOKING CONFIGURATION: "Command line test" - @BeforeMethod dustin.examples.TestNGDemo.setUp()
[VerboseTestNG] PASSED CONFIGURATION: "Command line test" - @BeforeMethod dustin.examples.TestNGDemo.setUp() finished in 2 ms
[VerboseTestNG] INVOKING: "Command line test" - dustin.examples.TestNGDemo.testIntegerArithmeticMultiplyIntegers()
[VerboseTestNG] PASSED: "Command line test" - dustin.examples.TestNGDemo.testIntegerArithmeticMultiplyIntegers() finished in 12 ms
[VerboseTestNG] INVOKING CONFIGURATION: "Command line test" - @AfterMethod dustin.examples.TestNGDemo.tearDown()
[VerboseTestNG] PASSED CONFIGURATION: "Command line test" - @AfterMethod dustin.examples.TestNGDemo.tearDown() finished in 1 ms
[VerboseTestNG] INVOKING CONFIGURATION: "Command line test" - @AfterClass dustin.examples.TestNGDemo.tearDownClass()
[VerboseTestNG] PASSED CONFIGURATION: "Command line test" - @AfterClass dustin.examples.TestNGDemo.tearDownClass() finished in 1 ms
[VerboseTestNG]
[VerboseTestNG] ===============================================
[VerboseTestNG]     Command line test
[VerboseTestNG]     Tests run: 1, Failures: 0, Skips: 0
[VerboseTestNG] ==============================================================================================
Command line suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================Deleting directory C:\Users\Dustin\AppData\Local\Temp\dustin.examples.TestNGDemo
test:
BUILD SUCCESSFUL (total time: 2 seconds)

上面的示例显示了开始使用TestNG是多么容易,特别是如果人们正从JUnit迁移到TestNG并正在使用NetBeans 7.2 beta。 当然,还有更给TestNG的不是这个,而是学习一个新的框架通常是最困难的,在开始和NetBeans 7.2得到一个开了一个快速启动。

参考: NetBeans 7.2在Inspired by Actual Events博客中从JCG合作伙伴 Dustin Marx 引入了TestNG 。

翻译自: https://www.javacodegeeks.com/2012/06/netbeans-72-introduces-testng.html

netbeans7.4

netbeans7.4_NetBeans 7.2引入了TestNG相关推荐

  1. NetBeans 7.2引入了TestNG

    代码生成的优点之一是能够查看如何使用特定的语言功能或框架. 正如我在< NetBeans 7.2 beta:更快,更有用>一文中所讨论的那样, NetBeans 7.2 beta提供了Te ...

  2. netbeans7.4_NetBeans 7.4 Beta提示警告无效的异常处理

    netbeans7.4 有许多例子说明Java异常处理可能比首次出现时要困难得多,Josh Bloch专门将一整章的< Effective Java> (两个版本)专门用于异常处理. Ja ...

  3. netbeans7.4_NetBeans 7.2 beta:更快,更有用

    netbeans7.4 NetBeans 7.2的beta版本引起了极大的兴奋. 在本文中,我将简要介绍一下此版本令人兴奋的原因(包括更好的性能,提供更多的提示以及集成FindBugs). NetBe ...

  4. netbeans7.4_NetBeans 7.4的本机Java打包

    netbeans7.4 成为" NetBeans 74 NewAndNoteworthy "页面的NetBeans 7.4的新功能之一是"本机打包 ",在该页面 ...

  5. netbeans7.4_NetBeans 7.1:创建自定义提示

    netbeans7.4 我已经在帖子中对我最喜欢的NetBeans提示进行了讨论,这些帖子中包含用于现代化Java代码的七个NetBeans提示和七个不可或缺的NetBeans Java提示 . 这两 ...

  6. 如何用TestNG满足开发自测?

    写在前边 用单元测试Junit完全可以满足日常开发自测,为什么还要学习TestNG,都影响了我的开发进度! 最近技术部老大突然宣布:全体开发人员必须熟练掌握自动化测试框架TestNG,就有了上边同事们 ...

  7. 技术部突然宣布:JAVA开发人员全部要会接口自动化测试框架

    整理了一些软件测试方面的资料.面试资料(接口自动化.web自动化.app自动化.性能安全.测试开发等),有需要的小伙伴可以文末加入我的学习交流qun,无套路自行领取~ 写在前边 用单元测试Junit完 ...

  8. TestNG学习随笔

    转载自:http://blog.sina.com.cn/s/blog_68f262210102vh5c.html 通过本人实践,文中所讲的程序可以正确运行,作用正确,并且浅显易懂.以下就是我从中摘录的 ...

  9. Spring Boot 和 testNG 和 eclipse背景色

    通过之前的博文,我们已经验证,Spring环境下完成access数据访问没有问题.下面我们直接在Spring环境下部署我们的升级项目. 1.导入Spring Boot Spring Boot是Spri ...

最新文章

  1. 软件工程与UML案例解析
  2. oracle的all函数,oracle函数 MIN([distinct|all]x)
  3. spring源码分析之spring jmx
  4. Boost Asio总结(3)异步通信
  5. ajax传递json数组php,怎么通过ajax传送json数组到php,并通过php将数据插入数据库
  6. win10电脑黑屏只有鼠标箭头_电脑黑屏后屏幕只有鼠标怎么办呢?
  7. 【数据库学习笔记】——操作sqlite(增删改查)以及cursor的方法介绍
  8. 实现用户操作指引功能
  9. python注释及语句分类
  10. 欧洲语言学习统一标准C1C2音频,北京通州区有没有西班牙语培训班(为何选择西班牙语)...
  11. html清除div浮动,HTML_清除浮动的最优方法:CSS,在CSS森林群里讨论一个margin的 - phpStudy...
  12. AMD 芯片被曝大量安全漏洞,Linux 之父怒评!
  13. 2020-05-06 ethtool源代码学习步骤
  14. Bailian2800 POJ NOI0113-04 垂直直方图【打印图形】
  15. python中json模块_python中的json模块
  16. 修改mysql字段长度
  17. 华为手机鸿蒙系统官方下载入口,华为鸿蒙系统升级入口
  18. 怎么在地图上标注自己的店铺
  19. Ubuntu将文件夹切换为英文
  20. 深度学习热点|超直观无公式图解Contrastive Predictive Coding从脸盲说起

热门文章

  1. 家的味道,家的感觉!!!
  2. 《四世同堂》金句摘抄(五)
  3. jQuery最简单的留言功能^-^
  4. 2015蓝桥杯省赛---java---C---2(立方尾不变)
  5. Android 隐藏底部三个虚拟按键
  6. android拦截短信获取短信内容,《英雄联盟手游》先锋测试招募说明:仅安卓用户...
  7. win10硬盘修复工具使用教程
  8. 高特权级代码段转向低特权级代码段(利用 ret(retf) 指令实现 jmp from ring0 to ring3)
  9. 实现简单的注解型MVC框架 —— 低配SpringMVC
  10. azure 部署java_jClarity:在Azure上升级到Java