Gotests: Modifying templates doesn't change generated code

Hi, I looked around and couldn't find this issue mentioned. I'm trying to modify the template used by go tests for generating table driven tests, I followed the help page on the jetbrains website and changed the proper template in the settings, but it doesn't apply (I already tried restarting the IDE too).

My guess is the -template_dir string (found on the package's github readme) command for the gotests package isn't properly set in the Idea settings, but I have no clue where it is located.

Thanks for any assistance provided.

EDIT: Added a screenshot of the changed template

1
9 comments
Official comment

Hi! I need a bit more details to help you:

> I followed the help page on the jetbrains website

 

Could you provide a link to the page, please?

 

> changed the proper template in the settings

 

Which one specifically? Please, provide a screenshot of the template you edited.

@Marat Khabibullin

The links are provided in the text (help page & github readme are both links)

I added a screenshot of the modified template.

0

So, if I get it correctly, your goal is to rename variables used in the generated template (tests -> testCases, test -> testCase). Am I right?

If true, it works as expected in my case. Please, see the GIF:

If you do the same and it doesn't work, please repeat the steps shown on the GIF and then send me the logs of the IDE (Help > Compress Logs).

Also, note that our test templates have nothing to do with https://github.com/cweill/gotests.

0

Generation of a single test does indeed work, sorry for not precising correctly.

What doesn't work  is when I generate tests for a file or package (CTRL+SHIFT+T, as described in the linked help page).

0

Oh, I see.

In that case, IDE does really invoke https://github.com/cweill/gotests. And, unfortunately, it is not possible to customize the template for it. We have plans to improve the situation. Please, follow:

https://youtrack.jetbrains.com/issue/GO-6283

2

Thx a lot for the info :)

0

Any development with this ? Still can't find the way of changing the "generate test" template (2022.2)

0

Mario.Gravel unfortunately, there is no way to change Test for function template on your own because the implementation language is complicated to use (Apache Velocity) and there are a lot of parameters to configure.

Please see and follow GO-10290.

May I ask you to leave a comment on that issue with parts of the template you would like to customize?

1

Thanks ! I replied on GO-10290

1

Please sign in to leave a comment.