Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

For JavaType allow to add properties if annotation is added #164

Closed
eddumelendez opened this issue Jan 12, 2017 · 9 comments
Closed

For JavaType allow to add properties if annotation is added #164

eddumelendez opened this issue Jan 12, 2017 · 9 comments
Assignees
Milestone

Comments

@eddumelendez
Copy link
Contributor

eddumelendez commented Jan 12, 2017

I'm moving from JUnit4 to JUnit5 and currently doing the following steps:

with JavaType c when { c.name().endsWith("Tests") } begin
  do addImport "org.junit.jupiter.api.Test"
  do addImport "org.springframework.test.context.junit.jupiter.SpringExtension"
  do addAnnotation "org.junit.jupiter.api.extension" "ExtendWith"
end

Additionally, I would like to register SpringExtension in ExtendWith to have @ExtendWith(SpringExtension.class)

@ddgenome
Copy link
Contributor

@eddumelendez can you provide more information here? Are you saying you want something like this?

if addAnnotation "blah" then addProperty "blech"

where addAnnotation would return true if the annotation is actually added but false if the annotation already existed?

@eddumelendez
Copy link
Contributor Author

@ddgenome I have updated my use case. Additionally, as you mention I would like to specify the property

@ddgenome
Copy link
Contributor

@eddumelendez could you provide the resulting diff you would like to see or before and after examples?

@eddumelendez
Copy link
Contributor Author

@ddgenome below you can find the current status, what my editor does and what I expect

Current file

public class SpringBootJunit5ApplicationTests {
}

After apply my editor

@ExtendWith
public class SpringBootJunit5ApplicationTests {
}

Expected

@ExtendWith(value = SpringExtension.class)
public class SpringBootJunit5ApplicationTests {
}

@ddgenome ddgenome self-assigned this Jan 13, 2017
ddgenome pushed a commit that referenced this issue Jan 13, 2017
Allow adding annotations of the form `Annotations(prop = Value)`.

Addresses #164
ddgenome pushed a commit that referenced this issue Jan 13, 2017
Allow adding annotations of the form `Annotations(prop = Value)`.

Addresses #164
@ddgenome
Copy link
Contributor

@eddumelendez can you take a look at the changes in #172 ? Rather than have a separate function to add properties to an annotation, I just changed things so you can add an annotation with properties. Your editor would look something like this:

with JavaType c when { c.name().endsWith("Tests") } begin
  do addImport "org.junit.jupiter.api.Test"
  do addImport "org.springframework.test.context.junit.jupiter.SpringExtension"
  do addAnnotation "org.junit.jupiter.api.extension" "ExtendWith(value = SpringExtension.class)"
end

Would that work for you?

@eddumelendez
Copy link
Contributor Author

Thanks @ddgenome looks good to fit my use case

@ddgenome
Copy link
Contributor

The PR is merged, so it will be in the next release.

@kipz kipz added this to the 0.10.0 milestone Jan 17, 2017
@kipz kipz added the Extension label Jan 17, 2017
@eddumelendez
Copy link
Contributor Author

I think this issue should be closed, since was released in 0.10.0, right?

@ddgenome
Copy link
Contributor

Yes, I was getting to it. 0.10.0 was only released a couple minutes ago!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants