Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplified public tests #2

Merged
merged 5 commits into from
Mar 22, 2024
Merged

simplified public tests #2

merged 5 commits into from
Mar 22, 2024

Conversation

doozMen
Copy link

@doozMen doozMen commented Mar 15, 2024

I think it is important to test the public interface without the need for @testable

Copy link

codecov bot commented Mar 16, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Owner

@drseg drseg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for doing this. You are correct of course, and I would have saved myself some issues if I'd done this much earlier!

I've left a few comments as requests for changes just to make things match up with the rest of the project and then I'd be happy to put it in.

import XCTest
import SwiftFSM

final class SimplifiedPublicTests: XCTestCase {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change file and test class name to PublicInterfaceTests, to accompany some changes to other file names that I made in preparation for this (PublicTests -> PublicFSMTests, FSMTests -> InternalFSMTests).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(make sure to pull the latest changes from master first)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good now thanks for the feedback

Comment on lines 30 to 35
func unlock() {
unlockCalled = true
}
func alarm() { alarmCalled = true }
func thankyou() { thankyouCalled = true }
func lock() { lockCalled = true }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline the unlock() body

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok done

Comment on lines 39 to 51
func testPublicInterface() throws {
let sut = try MyClass()
try sut.fsm.handleEvent(.coin)
XCTAssertTrue(sut.unlockCalled)
XCTAssertFalse(sut.thankyouCalled)
try sut.fsm.handleEvent(.coin)
XCTAssertTrue(sut.thankyouCalled)
try sut.fsm.handleEvent(.coin)
XCTAssertFalse(sut.lockCalled)
try sut.fsm.handleEvent(.pass)
XCTAssertTrue(sut.lockCalled)
try sut.fsm.handleEvent(.pass)
XCTAssertTrue(sut.alarmCalled)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line after each handleEvent()/XCTAssert... pair

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update indents to four spaces to match rest of project

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes my settings are different, keep forgetting that. Changed it!

stijn added 2 commits March 20, 2024 10:26
I think it is important to test the public interface
without the need for @testable
@drseg drseg merged commit 0d05694 into drseg:master Mar 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants