Comments (3)
OK - resolved my issue - and YES - it was ALL me.
I just finished a TDD course with James Grenning https://wingman-sw.com - and by watching his process very closely and comparing it to mine... well - he moves in tiny steps - verifies that each step compiles/links/works before moving on to the next one. So I decided to apply that method to my testing of PlayerRowView...
I thought - heck - I've not validated the unit-testing system works - I just assume it SHOULD! [foreshadow - I will end up with should all over me]
I decided to install the example ContentView example with the classic "Hello World" and see if that test will pass.
So going BACK to the instructions in Guide.... I copied the ContentView:
struct ContentView: View {
var body: some View {
Text("Hello, world!")
}
}
Then I copied the example UI Test
import XCTest
import ViewInspector // 1.
@testable import MyApp
extension ContentView: Inspectable { } // 2.
final class ContentViewTests: XCTestCase {
func testStringValue() throws { // 3.
let sut = ContentView()
let value = try sut.inspect().text().string() // 4.
XCTAssertEqual(value, "Hello, world!")
}
}
I don't know if you SEE IT... - but I did! the STEP #2
extension ContentView: Inspectable {}
I'd not written that in my test!
Reflecting... I want to BLAME the document... it leaves that out of the subsequent example code... OK fair. I skipped to them thinking I had all the setup I needed (WRONG). Could we get a better error message.... I don't know... could the ViewInspector validate that the test case extends or implements the Inspectable protocol? Seems like it could - maybe should.
Anyway - JAMES GRENNING FOR THE WIN!!! To go really really fast - you are going to need to SLOW d..o..w..n.
Thanks James!
from viewinspector.
Hey David, I did check the podcast you were on and got lots of gotchas where the confusion comes from when using the library (thanks!), so I know there I should put more descriptive error messages. As for the place where you stuck, you almost got it right - for inspecting the PlayerRowView
inside the ContentView
you need to use .view(PlayerRowView .self)
in the chain. You typed .view()
at some point, and code autocomplete would have helped you if you didn't have .hStack
or something else in the tail.
from viewinspector.
from viewinspector.
Related Issues (20)
- Inspecting custom modifier doesn't see removed views HOT 1
- Inspecting conditional toolbar content
- Inspect fails to find views due to `guardType(value:namespacedPrefixes:inspectionCall:)` incorrectly failing HOT 4
- Xcode 15.0 - Type mismatch: ButtonAction is not () -> () HOT 1
- Question: trying to use the (super) ViewInspector in non test code HOT 1
- Runtime warning when using . modelContainer modifier for SwiftData HOT 1
- View Hosting on watchOS in a Swift Package HOT 1
- iOS 17: Button style check HOT 1
- Views with .help become unfindable HOT 4
- Find fails when view has recursion inside of ForEach HOT 1
- Issue with .tint() modifier in Tests after updating Deployment Target to iOS 16
- Not found Shape in test layer HOT 2
- Accessing properties on a view that takes a generic HOT 2
- Does find(button: "xyz") find custom button `label:`s? HOT 4
- Interface buttons by ID HOT 1
- Is there a timeline on when we can expect 0.10.0 to be released? HOT 4
- View for `UIViewControllerRepresentable` is absent
- Only able to find the first AccessibilityIdentifier applied to a View, unless applied using a ViewModifier.
- Inspection of onTap gesture on custom Layout HOT 1
- Not able to test Charts framework elements/protocols
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viewinspector.