1

何らかの理由で、私のテストは毎回合格しています。追加しても

fail(@"failed");

Xcodeはまだ「テストが成功しました」と言っています

何か案は?

私の仕様は次のようになります

#import "SDRViewController.h"
#import <UIKit/UIKit.h>
#import <Kiwi/Kiwi.h>

SPEC_BEGIN(SDRViewControllerSpec)

describe(@"SDRViewController", ^{
    __block SDRViewController *viewController = [[SDRViewController alloc]init];

    beforeAll(^{
        [viewController setupCollectionView];
    });
    describe(@"viewController.collectionView", ^{

        describe(@"collectionViewLayout", ^{
            UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)viewController.collectionView.collectionViewLayout;
            [[flowLayout shouldNot]beNil];
            [[theValue(flowLayout.sectionInset) should]equal: theValue(UIEdgeInsetsZero)];
            fail(@"failed");
             });

        });
});

SPEC_END
4

1 に答える 1

2

単体テストが含まれていないため、コードが失敗することはありません。したがって、Xcode が成功と見なす失敗はゼロです。itテストするコードをブロック内にラップする必要があります。

describe(@"collectionViewLayout", ^{
    it(@"has a valid flow layout", ^{
        UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)viewController.collectionView.collectionViewLayout;
        [[flowLayout shouldNot]beNil];
        [[theValue(flowLayout.sectionInset) should]equal: theValue(UIEdgeInsetsZero)];
        fail(@"failed");
    });
});

Kiwi ブロックについて詳しく知りたい場合は、それに関する良い本があります: https://itunes.apple.com/us/book/test-driving-ios-development/id502345143?ls=1&mt=11

于 2015-05-10T12:30:20.687 に答える