{"id":2105,"url":"https://github.com/linkedin/LayoutTest-iOS","last_synced_at":"2025-08-02T23:31:52.312Z","repository":{"id":56919625,"uuid":"49520446","full_name":"linkedin/LayoutTest-iOS","owner":"linkedin","description":"Write unit tests which test the layout of a view in multiple configurations","archived":false,"fork":false,"pushed_at":"2024-05-03T21:24:10.000Z","size":1333,"stargazers_count":563,"open_issues_count":9,"forks_count":46,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-11-20T08:16:36.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://linkedin.github.io/LayoutTest-iOS/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linkedin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-12T18:31:08.000Z","updated_at":"2024-10-25T13:39:27.000Z","dependencies_parsed_at":"2022-08-21T04:20:13.543Z","dependency_job_id":"bc97dc0e-5cc1-4e77-8456-318e7b5a97d7","html_url":"https://github.com/linkedin/LayoutTest-iOS","commit_stats":{"total_commits":125,"total_committers":23,"mean_commits":5.434782608695652,"dds":0.632,"last_synced_commit":"0796ec35ddadc58181019a706dcd6b1492d40837"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkedin%2FLayoutTest-iOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkedin%2FLayoutTest-iOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkedin%2FLayoutTest-iOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkedin%2FLayoutTest-iOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkedin","download_url":"https://codeload.github.com/linkedin/LayoutTest-iOS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228503122,"owners_count":17930516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:03.672Z","updated_at":"2024-12-06T17:30:42.967Z","avatar_url":"https://github.com/linkedin.png","language":"Objective-C","funding_links":[],"categories":["Testing","Objective-C"],"sub_categories":["UI Testing","Other free courses"],"readme":"# Overview\n\nThis library enables you to write unit tests which test the layout of a view in multiple configurations. It tests the view with different data combinations and different view sizes. The library works in both Objective-C and Swift.\n\nTo learn how to use this library, there is a LinkedIn Learning course you can access completely for free authored by [Kyle Sherman](http://github.com/drumnkyle/). You can access it [here](https://www.linkedin.com/learning/learning-layouttest-for-ios-development). It will teach you how to use LayoutTest and all of its features by video tutorial.\n\n## Motivation\n\nWhen creating views, apps often have conditional logic which depends on the data used to setup the view. LayoutTest provides an easy way to define a data spec (a dictionary) which is then used to generate many different combinations of data. The library then uses this data to layout your view multiple times. For example, this is a small portion of the tests ran in our sample app:\n\n\u003cdiv align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/linkedin/LayoutTest-iOS/master/docs/images/catalog.png\" height=\"400px\" /\u003e\u003c/div\u003e\n\nIn just one test, your view will be laid out multiple times with different data. You can then run test assertions on these views to verify that the layout and view content is correct. Also, the library will run a few tests automatically such as checking for Autolayout errors, missing accessibility, and overlapping views.\nFinally, the library makes it easy to test each view with different sizes so you can verify the view will work on different devices.\n\n## Docs\n\nTo get started, you should take a look at the docs: \n\nhttps://linkedin.github.io/LayoutTest-iOS\n\n## Installation\n\nAdd to your unit test target:\n\n```\npod 'LayoutTest'\n```\n\nor\n\n```\npod 'LayoutTest/Swift'\n```\n\n## Example\n\nA simple test would look something like this. Check the docs for more detailed information and examples.\n\nObjective-C:\n```objective-c\n@interface SampleTableViewCellLayoutTests : LYTLayoutTestCase\n@end\n\n@implementation SampleTableViewCellLayoutTests\n- (void)testSampleTableViewCellLayout {\n  [self runLayoutTestsWithViewProvider:[SampleTableViewCell class]\n                            validation:^(UIView * view, NSDictionary * data, id context) {\n    // Add your custom tests here.\n  }];\n}\n@end\n\n@implementation SampleTableViewCell (LayoutTesting)\n  + (NSDictionary *)dataSpecForTest {\n    return @{\n      @\"text\": [[LYTStringValues alloc] init],\n      @\"showButton\": [[LYTBoolValues alloc] init]\n    }\n  }\n  + (UIView *)viewForData:(NSDictionary *)data\n                reuseView:(nullable UIView *)reuseView\n                     size:(nullable LYTViewSize *)size\n                  context:(id _Nullable * _Nullable)context {\n    SampleTableViewCell *view = (SampleTableViewCell *)reuseView ?: [SampleTableViewCell viewFromNib];\n    [view setupWithJSON:data];\n    return view;\n  }\n@end\n``` \nSwift:\n\n```swift\nclass SampleTableViewCellLayoutTests {\n  func testSampleTableViewCell() {\n    runLayoutTests() { (view: SampleTableViewCell, data: [NSObject: AnyObject], context: Any?) in\n      // Add your custom tests here.\n    }\n  }\n}\n\nextension SampleTableViewCell: LYTViewProvider {\n  class func dataSpecForTest() -\u003e [NSObject: AnyObject] {\n    return [\n      \"text\": LYTStringValues(),\n      \"showButton\": LYTBoolValues()\n    ]\n  }\n  class func viewForData(data: [NSObject: AnyObject],\n                    reuseView: UIView?,\n                         size: LYTViewSize?,\n                      context: AutoreleasingUnsafeMutablePointer\u003cAnyObject?\u003e) -\u003e UIView {\n    let cell = reuseView as? SampleTableViewCell ?? SampleTableViewCell.loadFromNib()\n    cell.setupWithDictionary(data)\n    return cell\n  }\n} \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkedin%2FLayoutTest-iOS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkedin%2FLayoutTest-iOS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkedin%2FLayoutTest-iOS/lists"}