https://kotlinlang.org logo
#getting-started
Title
# getting-started
h

Hullaballoonatic

10/02/2021, 9:55 PM
does kotlin test framework have any way to set up a list of parameters to a test function?
something tells me that that's too specific for generalizing depending on ng, js, jvm, native
s

Scott Kruse

10/03/2021, 2:44 AM
Hmmm list of parameters code smell for data class refactor?
h

Hullaballoonatic

10/03/2021, 8:49 PM
buddy... i'm not sure what you mean
i understand what all those words mean on their own, but your sentence doesn't make any sense to me...
in javascript with jest, i'd write the tests something like this:
Copy code
[
  { text: 'hello', expected: 'HELLO' }, 
  { text: 'apple', expected: 'APPLE' }
].forEach(({ text, expected }) => {
  it(`should return 'text' in uppercase`, () => {
    expect(uppercase(text)).toBe(expected);
  });
});
m

Matteo Mirk

10/04/2021, 2:35 PM
Oh I see, you’re looking for parameterized tests. If I remember correctly, the core kotlin.test doesn’t have this functionality, it is specific to the implementation being used (Junit/TestNG/JS/etc)
kotlin.test
only provides annotations and assertion functions independent from the platform, plus some specific implementations
👍 1
2 Views