diff --git a/HTMLKitTests/HTMLKitTreeConstructionTests.m b/HTMLKitTests/HTMLKitTreeConstructionTests.m
index 4a8a87a..befef66 100644
--- a/HTMLKitTests/HTMLKitTreeConstructionTests.m
+++ b/HTMLKitTests/HTMLKitTreeConstructionTests.m
@@ -7,6 +7,7 @@
//
#import
+#import
#import "HTMLKitTestObserver.h"
#import "HTML5LibTreeConstructionTest.h"
@@ -50,37 +51,40 @@
+ (void)addTestCaseForTestFile:(NSString *)testFile withTests:(NSArray *)tests toTestSuite:(XCTestSuite *)suite
{
- NSArray *allInvocations = [self testInvocations];
- for (NSInvocation *invocation in allInvocations) {
- XCTestCase *testCase = [[self alloc] initWithInvocation:invocation
- testName:testFile
- tests:tests];
- [suite addTest:testCase];
- }
+ IMP implementation = imp_implementationWithBlock(^ (HTMLKitTreeConstructionTests *instance){
+ [instance runTests];
+ });
+ const char *types = [[NSString stringWithFormat:@"%s%s%s", @encode(id), @encode(id), @encode(SEL)] UTF8String];
+
+ NSString *testName = [testFile.stringByDeletingPathExtension stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
+ NSString *selectorName = [NSString stringWithFormat:@"testPareser__%@", testName];
+ SEL selector = NSSelectorFromString(selectorName);
+ class_addMethod(self, selector, implementation, types);
+
+ NSMethodSignature *signature = [self instanceMethodSignatureForSelector:selector];
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
+ invocation.selector = selector;
+
+ XCTestCase *testCase = [[self alloc] initWithInvocation:invocation tests:tests];
+ [suite addTest:testCase];
}
#pragma mark - Instance
-- (instancetype)initWithInvocation:(NSInvocation *)invocation
- testName:(NSString *)testName
- tests:(NSArray *)tests
+- (instancetype)initWithInvocation:(NSInvocation *)invocation tests:(NSArray *)tests
{
self = [super initWithInvocation:invocation];
if (self) {
- _testName = testName;
_testsList = tests;
}
return self;
}
-- (NSString *)name
+- (NSString *)description
{
- NSInvocation *invocation = [self invocation];
- NSString *title = self.testName.stringByDeletingPathExtension;
- return [NSString stringWithFormat:@"-[%@ %@_%@]", self.class, NSStringFromSelector(invocation.selector), title];
+ return self.name;
}
-- (NSString *)description
#pragma mark - Setup
- (void)setUp
@@ -102,13 +106,15 @@
#pragma mark - Tests
-- (void)testParser
+- (void)runTests
{
for (HTML5LibTreeConstructionTest *test in self.testsList) {
+ NSString *testInput = test.data;
+
+ [_observer addCaseForHTML5LibTestWithInput:testInput];
+
+ HTMLParser *parser = [[HTMLParser alloc] initWithString:testInput];
HTMLElement *contextElement = test.documentFragment;
-
- HTMLParser *parser = [[HTMLParser alloc] initWithString:test.data];
-
NSArray *actual = nil;
if (contextElement == nil) {
actual = [parser parseDocument].childNodes.array;