Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Possible to mock Jira data in unit tests?

uidev March 7, 2021

Is there any sort of unit test fixture (besides integration tests) that allow me to create users, issues, and the like in order to create test data in memory for quick and efficient unit testing without waiting for a Jira instance to start?

I'm implementing test fixture mock data manually, such as a test fixture that instantiates a new ApplicationUser or new CustomField, in order to create dummy data for unit testing my Jira plugin (java) backend. Doing so let's me prototype without slowly testing and debugging against a Jira dev server. Each of these Jira data classes mentioned above is an interface with 20 - 50 methods that must be implemented - quite a lot of code! Also, the implementation details I am dangerously guessing, such as how id and name values are set for each class following patterns I detect from REST API calls (e.g. custom field ids seem to start with "customfield_").

I'm happy with my test fixtures - they work, but it's a lot of code and I figured someone else must have done this before enough times to share a fixture? The benefit is developer efficiency with lightning fast unit tests. Starting Jira server locally takes my puny laptop a couple of minutes, then navigating pages can even take 10 - 20 seconds each ;)

 

I should clarify too - I know how to "mock" (with mockito, Junit) but that is not what I'm asking. Mocks still need to return some kind of data, which is ultimately an Issue, CustomField, or some other Jira data and that is what I'm looking to automate the creation of for testing purposes.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events