当前位置: 首页 > news >正文

做网站一年的维护费用是多少百度竞价怎么做开户需要多少钱

做网站一年的维护费用是多少,百度竞价怎么做开户需要多少钱,wordpress主题模板下载,最佳搜索引擎磁力王第2关:Junit注解 任务描述 给出一个带有注解的Junit代码及其代码打印输出,要求学员修改注解位置,让输出结果变为逆序。 相关知识 Junit注解 Java注解((Annotation)的使用方法是" 注解名" 。借助注解&a…

第2关:Junit注解
任务描述

给出一个带有注解的Junit代码及其代码打印输出,要求学员修改注解位置,让输出结果变为逆序。

相关知识
Junit注解

Java注解((Annotation)的使用方法是"@ + 注解名" 。借助注解,我们可以在编程中通过简单的注解来实现一些功能。在junit中常用的注解有 @Test、@Ignore、@BeforeClass、@AfterClass、@Before、@After 下表列出了这些注释的概括:

具体解释如下:

1、@Test,表明此方法为测试方法。

2、@Before,用此注解修饰的方法在每个test方法运行前执行

3、@BeforeClass,用此注解修饰的方法将在所有方法运行前被执行,是一个static方法,只执行一次。

4、@After,用此注解修饰的方法在每个test方法运行后执行

5、@AfterClass,用此注解修饰的方法将在所有方法运行后被执行,也是一个static方法,只执行一次。

6、@Ignore,用此注解修饰的方法会被Junit忽略。

代码示例

这里新建一个JunitAnnotation.java,把上面所讲的注解全部加到某个测试函数之前,这些注解的作用一目了然:

 
  1. package com.trustie.junittest;
  2. import static org.junit.Assert.*;
  3. import java.util.*;
  4. import org.junit.*;
  5. public class AnnotationsTest {
  6. private ArrayList testList;
  7. @BeforeClass
  8. public static void onceExecutedBeforeAll() {
  9. System.out.println("@BeforeClass: onceExecutedBeforeAll");
  10. }
  11. @Before
  12. public void executedBeforeEach() {
  13. testList = new ArrayList();
  14. System.out.println("@Before: executedBeforeEach");
  15. }
  16. @AfterClass
  17. public static void onceExecutedAfterAll() {
  18. System.out.println("@AfterClass: onceExecutedAfterAll");
  19. }
  20. @After
  21. public void executedAfterEach() {
  22. testList.clear();
  23. System.out.println("@After: executedAfterEach");
  24. }
  25. @Test
  26. public void EmptyCollection() {
  27. assertTrue(testList.isEmpty());
  28. System.out.println("@Test: EmptyArrayList");
  29. }
  30. @Test
  31. public void OneItemCollection() {
  32. testList.add("oneItem");
  33. assertEquals(1, testList.size());
  34. System.out.println("@Test: OneItemArrayList");
  35. }
  36. @Ignore
  37. public void executionIgnored() {
  38. System.out.println("@Ignore: This execution is ignored");
  39. }
  40. }

如果我们运行上面的测试,控制台输出将是下面:

 
  1. @BeforeClass: onceExecutedBeforeAll
  2. @Before: executedBeforeEach
  3. @Test: EmptyArrayList
  4. @After: executedAfterEach
  5. @Before: executedBeforeEach
  6. @Test: OneItemArrayList
  7. @After: executedAfterEach
  8. @AfterClass: onceExecutedAfterAll
编程要求

本关的编程任务是在JunitAnnotation.java中修改测试函数对应的注解,使得原代码输出结果变为逆序。

本关涉及的代码文件JunitAnnotation.java的代码如下:

 
  1. package step2;
  2. import org.junit.After;
  3. import org.junit.AfterClass;
  4. import org.junit.Before;
  5. import org.junit.BeforeClass;
  6. import org.junit.Ignore;
  7. import org.junit.Test;
  8. public class JunitAnnotation {
  9. /*
  10. *以下Junit测试程序的输出结果为:
  11. *in before class
  12. *in before
  13. *in test
  14. *in after
  15. *in after class
  16. *请修改下面Begin/End内各个测试函数的注解,使输出结果逆序
  17. */
  18. /***********************Begin**************************/
  19. //execute before class
  20. @BeforeClass
  21. public static void beforeClass() {
  22. System.out.println("in before class");
  23. }
  24. //execute after class
  25. @AfterClass
  26. public static void afterClass() {
  27. System.out.println("in after class");
  28. }
  29. //execute before test
  30. @Before
  31. public void before() {
  32. System.out.println("in before");
  33. }
  34. //execute after test
  35. @After
  36. public void after() {
  37. System.out.println("in after");
  38. }
  39. //test case
  40. @Test
  41. public void test() {
  42. System.out.println("in test");
  43. }
  44. /************************End***************************/
  45. }
评测说明

本关卡的测试文件是TestRunner.java,该文件进行了函数封装且学员不可见,用于验证学员的Junit测试代码是否正确。

具体测试过程如下:

1.平台自动编译生成TestRunner.exe; 2.平台运行TestRunner.exe; 3.获取TestRunner.exe输出,并将其输出与预期输出对比:如果一致则测试通过,否则测试失败。

预期输入: 预期输出:

 
  1. in after class
  2. in after
  3. in test
  4. in before
  5. in before class
  6. true

友情提示

1.请不要直接println最终输出,否则平台发现此类情况后,将一律扣掉本关经验值,并且追加处罚措施。

2.学员答题时请尽量手敲代码,请勿从实训讲解代码片段中复制代码段粘贴到答题区域作答,复制的内容会保留一些格式和字符,导致编译失败。

开始你的任务吧,祝你成功!

代码如下

package step2;import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;public class JunitAnnotation {/**以下Junit测试程序的输出结果为:*in before class*in before*in test*in after*in after class*请修改下面Begin/End内各个测试函数的注解,使输出结果逆序*//***********************Begin**************************/@BeforeClasspublic static void afterClass() {System.out.println("in after class");}@Beforepublic void  after() {System.out.println("in after");}@Afterpublic void before() {System.out.println("in before");}@AfterClasspublic static void beforeClass() {System.out.println("in before class");}@Testpublic void test() {System.out.println("in test");}/************************End***************************/
}

http://www.khdw.cn/news/70208.html

相关文章:

  • 网站建设如何交税高端营销型网站
  • 网站功能报价明细表如何推广网站方法
  • 泰安工程建设信息网站百度关键词快速优化
  • 在线crm管理系统搜索引擎优化是什么
  • 网站设置了权限域名查询 站长查询
  • 米拓建站怎么样百度新闻官网首页
  • 如何使网站能被百度搜到怎么做链接推广产品
  • 建立动态网站开发目的债务优化是什么意思
  • 哈尔滨网站制作营销网站seo推广
  • 有了网站 怎么做排名优化友情链接交换工具
  • 做购物网站 营业范围是什么百度关键词搜索技巧
  • 高端网站建设的小知识成人教育培训机构
  • 山东天狐做网站cms学网络营销好就业吗
  • 重庆合川企业网站建设seo教程 百度网盘
  • 邯郸网站建设公司百度产品大全入口
  • 深圳招聘网站长尾词seo排名优化
  • 上海哪家公司可以做网站职业培训网络平台
  • 衡水网站托管互联网广告公司排名前十
  • 做代购网站如何缴税直接下载app
  • 卖书网站开发的背景网络营销的策划方案
  • 石家庄网站排名优化哪家好app推广的常用方法
  • 房地产网站怎样建设才能快速盈利网站搜索引擎优化报告
  • 成都个人兼职做网站微网站建站平台
  • 管理咨询公司业务淮南网站seo
  • 武汉做营销型网站推广国内新闻最新消息
  • 网站做外链什么意思千锋教育郑州校区
  • 找做网站的个人网站发布与推广怎么写
  • 珠海互联网推广seo软件工具箱
  • 济南快速网站制作公司关键字搜索
  • 河南网站搭建天津网站优化公司