首页 文章 精选 留言 我的

精选列表

搜索[网站开发],共10000篇文章
优秀的个人博客,低调大师

Android开发中的单元测试

1、测试类一定要extendsAndroidTestCase 类 2、测试方法要以test开头,并抛出异常 3、在测试方法中new出要测试的类,然后对应其功能进行测试 (经常会用到Assert.assertEquals(a,b);) package com.zhy.junitExample.test; import com.zhy.servers.server; import android.test.AndroidTestCase; public class serverTest extends AndroidTestCase { public void testsave() throws Exception{ server ser = new server(); ser.save(); } } 4、在AndroidMainfest中要添加 <uses-library android:name="android.test.runner" /> 加入测试库 <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.zhy.junitExample" /> 注意android:targetPackage是你要测试的类的项目中的Package(打开其AndroidMainfest,即可看到),不是项目中具体的包名。 5、green is YES,red is NO! 本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/04/13/2445852.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Oracle开发常用函数与存储过程

1.输出用"、"符合分隔多个作者列表 Fuc_Get_AuthorName 2.获取数据库表的主键最大值 Fuc_Get_MaxId 3.根据分割类来分割字符串 sf_split_string 4.计算周岁的函数 Fuc_Get_FullAge 5.获取数据表架构信息 SQL 6.带排序的oracle分页存储过程(来自网络) Code 本文转自peterzb博客园博客,原文链接:http://www.cnblogs.com/peterzb/archive/2009/06/09/1500031.html,如需转载请自行联系原作者。

优秀的个人博客,低调大师

【iOS 开发】延迟执行方法小总结

当需要实现类似“轮询”这种操作的时候,我们可能会希望有一个“被放缓了的” for 循环 —— 即当某次操作执行后,稍等一下再去执行下一次操作。这时有几种方法可以供我们使用,来实现这种效果,下面对比总结一下。 perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval) extension NSObject { open func perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval, inModes modes: [RunLoopMode]) open func perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval) open class func cancelPreviousPerformRequests(withTarget aTarget: Any, selector aSelector: Selector, object anArgument: Any?) open class func cancelPreviousPerformRequests(withTarget aTarget: Any) } extension RunLoop { open func perform(_ aSelector: Selector, target: Any, argument arg: Any?, order: Int, modes: [RunLoopMode]) open func cancelPerform(_ aSelector: Selector, target: Any, argument arg: Any?) open func cancelPerformSelectors(withTarget target: Any) } 这是系统提供的 API,其中最简单的第 2 个方法可以通过指定方法、参数、延迟时间来实现延迟调用。 优点:使用简单、自带根据 target 取消调用的机制 并且可以指定对象、方法来取消延迟调用 使得这个方法可以完成一些复杂的延迟调用机制缺点:系统帮你自动完成了很多操作,使得它不像定时器(NSTimer)那样高度可控。 scheduledTimer(timeInterval ti: TimeInterval, target aTarget: Any, selector aSelector: Selector, userInfo: Any?, repeats yesOrNo: Bool) -> Timer open class Timer : NSObject { public /*not inherited*/ init(timeInterval ti: TimeInterval, invocation: NSInvocation, repeats yesOrNo: Bool) open class func scheduledTimer(timeInterval ti: TimeInterval, invocation: NSInvocation, repeats yesOrNo: Bool) -> Timer public /*not inherited*/ init(timeInterval ti: TimeInterval, target aTarget: Any, selector aSelector: Selector, userInfo: Any?, repeats yesOrNo: Bool) open class func scheduledTimer(timeInterval ti: TimeInterval, target aTarget: Any, selector aSelector: Selector, userInfo: Any?, repeats yesOrNo: Bool) -> Timer } 通过常见的定时器也可以实现延迟调用,把 repeats 参数置为 false,可以实现类似上面的 perform 的效果。 优点:定时器状态可控,可以重新赋值,可以查看是否 valid 等缺点:对比上面的 perform 方法可以直接传参,这里想要传参的话只能曲线救国: 把参数放在 timer 的 userInfo 里面,再把 timer 本身当成参数传递(这里使得代码可读性稍稍变差,但是好在 userInfo 里面什么都能放,这使得我们可以同时传递多个参数了) 如果你的代码可以不兼容 iOS 10 以下的系统,新的 API 可以让你不通过 selector 而是通过 block (closure) 执行代码 asyncAfter(deadline: DispatchTime, qos: DispatchQoS = default, flags: DispatchWorkItemFlags = default, execute work: @escaping @convention(block) () -> Swift.Void) DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 1, execute: { print("1 second after") }) 上面这段代码,可以在 1 秒之后,通过主线程执行 print。值得注意的是,设定时间的时候,有两种类型,一种是 DispatchTime,这个时间本质上是相对时间,它会在系统休眠的时候暂停,另外一种是 DispatchWallTime,这个时间正如其名,是“墙上的挂钟时间”,是绝对时间,比如你可能希望某一个任务准确地在x小时、x分钟、x秒之后执行,这段时间可能发生任何事情,这时推荐使用 DispatchWallTime. 神奇而伟大的 GCD 这里就不多做介绍了,有太多文章讲解它了优点:执行的是闭包,可以随意传参缺点:一旦开启,无法取消,只能提前在闭包里面添加严谨的逻辑判断了

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册