Giter VIP home page Giter VIP logo

Comments (3)

davidakoontz avatar davidakoontz commented on May 30, 2024 1

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.

nalexn avatar nalexn commented on May 30, 2024

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.

davidakoontz avatar davidakoontz commented on May 30, 2024

from viewinspector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.