-
Notifications
You must be signed in to change notification settings - Fork 637
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
Reflection Matchers #614
Comments
These kind of things would be great if we could assert on the annotation too. For example
|
Or something similar |
|
That's way better |
One more matcher we would add a lambda to. I don't think it's a big problem |
I think it could be a new pattern we could use to great effect. Anything where we are testing a type, we allow the type to be used in the lambda.
|
But then, is I suppose a more correct way would be to add an
|
What does the |
I believe that But I don't mind |
I'm happy to discuss alternative nomenclature. Or as you say allow chained
matchers.
…On Mon, 28 Jan 2019, 15:43 Leonardo Colman Lopes ***@***.*** wrote:
I believe that shouldBeX looks like a "terminal" operation, and it
doesn't seem to be a lambda operation.
But I don't mind
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#614 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtZGjPRHy6kgMQG-IUMYCBbY89knYGQks5vHxqZgaJpZM4aWDkv>
.
|
Does the development of this issue worth? Because annotations are not "business rules" to be validated on the test. |
It's still useful, you may be testing a framework, like I am doing at the
moment.
…On Fri, 5 Jul 2019 at 08:22, Gustavo Fão Valvassori < ***@***.***> wrote:
Does the development of this issue worth? Because annotations are not
"business rules" to be validated on the test.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#614>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFVSGVCV57F7UVCFJCA4Z3P55DKHANCNFSM4GSYHEXQ>
.
|
Okay. I can do this issue this weekend. |
awesome
…On Fri, 5 Jul 2019 at 09:12, Gustavo Fão Valvassori < ***@***.***> wrote:
Okay. I can do this issue this weekend.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#614>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFVSGRU5BQXVJFPIROJRP3P55JDDANCNFSM4GSYHEXQ>
.
|
@sksamuel @Kerooker I already created these matchers:
Do you know others that can be useful? |
A.shouldHaveMemberProperty. Also the above that takes a lamba of KProperty to Unit A.shouldHavePrimaryConstructor { constructor-> } |
KFunction.shouldHaveReturnType |
Okay, 'til now, I created the following matchers:
In my TODO List I still have those:
|
Looks good.
…On Mon, 8 Jul 2019 at 20:55, Gustavo Fão Valvassori < ***@***.***> wrote:
Okay, 'til now, I created the following matchers:
Reflection
kclass.shouldHaveAnnotations() Asserts that the class has some annotation
kclass.shouldHaveAnnotations(n) Asserts that the class has exactly N
annotation
kclass.shouldBeAnnotatedWith<T>() Asserts that the class is annotated
with the given type
kclass.shouldBeAnnotatedWith<T> { block } Asserts that the class is
annotated with the given type, and then, runs the block with the annotation
kclass.shouldHaveFunction(name) Asserts that the class have a function
with the given name
kclass.shouldHaveFunction(name) { block } Asserts that the class have a
function with the given name, and then, runs the block with the function
kclass.shouldHaveMemberProperty(name) Asserts that the class have a
member property with the given name
kclass.shouldHaveMemberProperty(name) { block } Asserts that the class
have a member property with the given name, and then, runs the block with
the function
kfunction.shouldHaveAnnotations() Asserts that the function has some
annotation
kfunction.shouldHaveAnnotations(n) Asserts that the function has exactly
N annotation
kfunction.shouldBeAnnotatedWith<T>() Asserts that the function is
annotated with the given type
kfunction.shouldBeAnnotatedWith<T> { block } Asserts that the function is
annotated with the given type, and then, runs the block with the annotation
kfunction.shouldHaveReturnType<T>() Asserts that the function returns the
given type
kproperty.shouldBeOfType<T>() Asserts that the property is of the given
type
kcallable.shouldHaveVisibility(visibility) Asserts that the member have
the given visibility
kcallable.shouldBeFinal() Asserts that the member is final
ktype.shouldBeOfType<T>() Asserts that the KType has the type T
In my TODO List I still have those:
- kclass.shouldBeSubtypeOf()
- kclass.shouldBeData()
- kclass.shouldBeSealed()
- kclass.isCompanion()
- kclass.shouldHavePrimaryConstructor()
- kclass.shouldHaveVisibility(visibilty)
- kfunction.shouldBeInline()
- kfunction.shouldBeInfix()
- kproperty.shouldBeConst()
- kproperty.shouldBeLateInit()
- kcallable.shouldBeOpen()
- kcallable.shouldBeAbstract()
- kcallable.shouldBeSuspend()
- kcallable.shouldHaveParameters(listOf()) // Names of parameters
- kcallable.shouldBeCalledWith(listOf()) // Types of parameter
- kcallable.shouldHaveParameterWithName(name) // also accept lambda
- kparameter.shouldBeOfType()
- kparameter.shouldBeOptional()
- kparameter.shouldBeVararg()
- kparameter.shoudBeAtIndex(index) // check the position of the
parameter
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#614>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFVSGUSMSOTF5JBUP52NI3P6PV25ANCNFSM4GSYHEXQ>
.
|
We can include this in 3.4 which we will release in the next few days, if it's ready @faogustavo |
I've been a little bit busy these last days. I'll open the PR to you start the review but there are a few methods missing. |
That would be great, we can merge what's ready.
…On Tue, 16 Jul 2019 at 11:27, Gustavo Fão Valvassori < ***@***.***> wrote:
We can include this in 3.4 which we will release in the next few days, if
it's ready @faogustavo <https://github.com/faogustavo>
I've been a little bit busy these last days. I'll open the PR to you start
the review but there are a few methods missing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#614>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFVSGXT2VHSDER2TLTZQCDP7XZFTANCNFSM4GSYHEXQ>
.
|
Would it be useful to have matchers like
a.shouldHaveMethod("foo")
anda.shouldHaveAnnotation("foo")
and so on.The text was updated successfully, but these errors were encountered: