# How to create a parameterized base test class in Kotlin

DevFeed: [How to create a parameterized base test class in Kotlin](<https://devfeed.tech/articles/how-to-create-a-parameterized-base-test-class-in-kotlin-25575.md>)

Original publisher: [Read original article](<https://www.marcogomiero.com/posts/2023/parameterized-kotlin-base-test/>)

Author: Marco Gomiero

Published: 2023-01-31T00:00:00Z

Content type: tutorial

Language: en

Sources: [Posts on Marco Gomiero](<https://devfeed.tech/sources/posts-on-marco-gomiero.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [configuration](<https://devfeed.tech/topics/configuration.md>)

Tags: [argument](<https://devfeed.tech/tags/argument.md>), [class](<https://devfeed.tech/tags/class.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [constructor](<https://devfeed.tech/tags/constructor.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

This tutorial explains how to create a parameterized base test class in Kotlin using JUnit 4's Parameterized test runner. It describes defining test arguments in a companion object, accepting an argument in the base-class constructor, and having test classes reuse the shared setup while running with different arguments.

## Source excerpt

One exciting feature of JUnit 4 (and 5 as well, but this post will be focused on JUnit 4) is the possibility of running the same test with different input arguments. That is made possible by a custom test runner called Parameterized, which will inject the provided arguments in the constructor of the test class. Instead, the different arguments must be defined in the companion object of the test class.