arrow-kt / arrow-kt/arrow-proofs
Local providers
- Dominant language
- Kotlin
- Stars
- 10
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
This feature is to allow providing proofs with different parents, so instead of getting an ambiguous proof error, we get the closest one.
It is totally oriented to testing, but it can/could be used outside of tests if needed.
### Android common architecture example.
It is usual to have this layers:
- UI
- ViewModel/Presenter
- Use cases
- Repositories
- Datasources
Generally, one or more datasources are passed via repositories constructor implementation. At same time, one or repositories are passed via constructor to the use cases. Finally the ViewModel receives via constructor one or more use cases and the ViewModel is injected into the UI.
As you can see, technically you can create an integration test (understanding integration tests as a test that tests multiple components) for ViewModels manually by passing all instances via the constructor.
That process can be tedious and in those kinds of tests is in which a DI framework can shine.
If I want to test my ViewModel, in a lot of applications I only want to change the remote by using a mock web server or a mock engine if you are using Ktor, or in other words, providing multiple local JSON to be able to tests multiple paths, not only multiple happy paths, errors, and so on.
At the same time, those tests are written like unit tests, there is no emulator, so they run quickly, and testing the ViewModel implies you are testing the rest of the layers. In my opinion unit testing shines on libraries or edge cases, but in applications, the integration tests are the best way to get a robust product.
So I want to build tests that can have a complex graph of dependencies without maintaining manually that graph, so a simple test can be:
```kotlin
class MyTest {
@Test
`some viewmodel test`() {
// I need a way to replace the ktor engine (`OkHhttp`) with the `MockEngine`
// in order to do a test
// ...
}
}
```
Our plugin should allow doing easily:
```kotlin
class MyTest {
@Provider
val engine = MockEngine()
@Test
`some viewmodel test`() {
// ...
}
}
```
Or even, if possible
```kotlin
class MyTest {
@Test
`some viewmodel test 1`() {
@Provider
val engine = MockEngine()
// ...
}
@Test
`some viewmodel test 2`() {
@Provider
val engine = MockEngine()
// ...
}
}
```
Probably there are use cases outside tests, I am not totally sure, but I would add a flag to block this usage to only tests, and enable it globally with that flag.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no repository files, tests, or entry points. Start by mapping the Kotlin plugin's current provider and proof resolution, then define how class- and method-scoped @Provider values should select the closest parent and verify both examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- testing, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100