博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
test2
阅读量:6893 次
发布时间:2019-06-27

本文共 2935 字,大约阅读时间需要 9 分钟。

  hot3.png

//

//  TestSimpleTests.swift

//  TestSimpleTests

//

//  Created by sus001 on 16/5/30.

//  Copyright © 2016年 njsus. All rights reserved.

//

 

import XCTest

@testable import TestSimple

 

class TestSimpleTests: XCTestCase {

    var viewController: ViewController?

//    测试月应纳税额不超过1500元,用例1

    func testCalculateLevel1(){

        let dbRevenue = 5000

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController!.calculate(strRevenue)

        print(strTax)

//        XCTAssertTrue(strTax?.doubleValue == 45, "期望值是45:,实际值是:\(strTax!)")

        XCTAssertEqual(strTax?.doubleValue, 45.0, "测试用例1失败,实际值是\(strTax)")

    }

    //    测试月应纳税额不超过1500-4500元,用例2

    func testCalculateVevel2(){

        let dbRevenue = 8000

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController!.calculate(strRevenue)

         XCTAssertTrue(strTax?.doubleValue == 345, "期望值是345:,实际值是:\(strTax!)") 

    }

    //    测试月应纳税额不超过4500 - 9000元,用例3

    func testCalculateVevel3(){

        let dbRevenue = 12500

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController?.calculate(strRevenue)

        XCTAssertTrue(strTax?.doubleValue == 1245, "期望值是1245:,实际值是:\(strTax!)")

    }

    //    测试月应纳税额不超过9000 - 35000元,用例4

    func testCalculateVevel4(){

        let dbRevenue = 38500

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController?.calculate(strRevenue)

        XCTAssertTrue(strTax?.doubleValue == 7745, "期望值是7745:,实际值是:\(strTax!)")

    }

    //    测试月应纳税额不超过35000 - 55000元,用例5

    func testCalculateVevel5(){

        let dbRevenue = 58500

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController?.calculate(strRevenue)

        XCTAssertTrue(strTax?.doubleValue == 13745, "期望值是13745:,实际值是:\(strTax!)")

    }

    //    测试月应纳税额不超过55000 - 80000元,用例6

    func testCalculateVevel6(){

        let dbRevenue = 83500

        

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController?.calculate(strRevenue)

 

        XCTAssertTrue(strTax?.doubleValue == 22495, "期望值是22495:,实际值是:\(strTax!)")

    }

    //    测试月应纳税额超过80000元,用例7

    func testCalculateVevel7(){

        let dbRevenue = 103500

        let strRevenue = NSString(format: "\(dbRevenue)%f",locale: nil )

        let strTax = viewController?.calculate(strRevenue)

        XCTAssertTrue(strTax?.doubleValue == 31495, "期望值是31495:,实际值是:\(strTax!)")

    }

    override func setUp() {

        super.setUp()

        // Put setup code here. This method is called before the invocation of each test method in the class.

        self.viewController = ViewController()

    }

    

    override func tearDown() {

        // Put teardown code here. This method is called after the invocation of each test method in the class.

        self.viewController = nil

        super.tearDown()

        

    }

    

    func testExample() {

        // This is an example of a functional test case.

        // Use XCTAssert and related functions to verify your tests produce the correct results.

    }

    

    func testPerformanceExample() {

        // This is an example of a performance test case.

        self.measureBlock {

            // Put the code you want to measure the time of here.

        }

    }

    

}

 

转载于:https://my.oschina.net/ldm95/blog/689726

你可能感兴趣的文章
css3常用属性总结(1)
查看>>
全国416个本科专业被撤销!哪些新专业或成为“爆款”?
查看>>
SQLServer之创建索引视图
查看>>
面试集锦(六)数据结构(2)
查看>>
VimWiki的一些技巧
查看>>
GMQT全球通用积分重磅推出
查看>>
spring cloud构建互联网分布式微服务云平台-路由网关(zuul)
查看>>
Parasoft dotTEST(10.4.1)更新亮点——在.NET应用程序中构建安全性
查看>>
Nginx 配置
查看>>
混沌工程究竟用来解决什么问题?
查看>>
如何写好一片文章
查看>>
vue项目前后端实现
查看>>
BCH升级日期将至,社区组织开始为11月“硬分叉”做准备
查看>>
2018最新版直播系统源码:功能和步骤详解
查看>>
vue的事件处理,冒泡和捕获
查看>>
没错,我就是要吹爆Angular
查看>>
Andoid屏幕适配终极手段(小编用过最得劲的dp适配)
查看>>
一张图带你了解Aspose 2019年的产品线
查看>>
一篇关于MySQL server层执行查询语句的注释,非常棒
查看>>
js执行过程之上下文对象(Context)
查看>>