All Projects → EranBoudjnah → TestIt

EranBoudjnah / TestIt

Licence: MIT license
Generate unit testing boilerplate from kotlin files.

Programming Languages

kotlin
9241 projects
shell
77523 projects

Projects that are alternatives of or similar to TestIt

unittest expander
A library that provides flexible and easy-to-use tools to parameterize Python unit tests, especially those based on unittest.TestCase.
Stars: ✭ 12 (-62.5%)
Mutual labels:  unit-testing, unittest, unit-tests, unit-test
Nunit cshaprp cheatsheet
Example implementations of each attribute available in Nunit2 unit Testing Framework using C# .NET.
Stars: ✭ 14 (-56.25%)
Mutual labels:  unit-testing, unittest, unit-test
Kotlinmvparchitecture
Clean MVP Architecture with Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Added Unit Tests(Kotlin Tests)!
Stars: ✭ 143 (+346.88%)
Mutual labels:  unit-testing, unittest, unit-test
ionic-workflow-guide
Create a full and powerful worflow with Ionic (Unit Testing, Environment variables, Automatic documentation, Production App Server, Automatic deployment)
Stars: ✭ 46 (+43.75%)
Mutual labels:  unit-testing, unit-tests, unit-test
Capture Stream
Capture stream output.
Stars: ✭ 10 (-68.75%)
Mutual labels:  unit-testing, unittest
VCore
VCore is a Swift collection containing objects, functions, and extensions that I use for my projects
Stars: ✭ 32 (+0%)
Mutual labels:  unittest, unit-test
springboot-junit5-mockito2
Show case for how to use junit 5 and mockito 2 for unit testing and integration test in spring boot 2
Stars: ✭ 18 (-43.75%)
Mutual labels:  unit-testing, mockito
Kotlinrxmvparchitecture
Clean MVP Architecture with RxJava + Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Includes Unit Tests(Kotlin Tests)!
Stars: ✭ 94 (+193.75%)
Mutual labels:  unit-testing, unit-test
Android Testing With Kotlin
Android Testing With Kotlin
Stars: ✭ 393 (+1128.13%)
Mutual labels:  unit-testing, mockito
Mockstar
Demo project on How to be a Mockstar using Mockito and MockWebServer.
Stars: ✭ 53 (+65.63%)
Mutual labels:  unit-testing, mockito
Cuckoo
Boilerplate-free mocking framework for Swift!
Stars: ✭ 1,344 (+4100%)
Mutual labels:  unit-testing, mockito
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report.
Stars: ✭ 3,019 (+9334.38%)
Mutual labels:  unit-testing, unit-test
Bash unit
bash unit testing enterprise edition framework for professionals
Stars: ✭ 419 (+1209.38%)
Mutual labels:  unit-testing, unittest
Unit Threaded
Advanced unit test framework for D
Stars: ✭ 100 (+212.5%)
Mutual labels:  unit-testing, unittest
Moderncppci
This is an example of doing a Modern C++ project with CI
Stars: ✭ 109 (+240.63%)
Mutual labels:  unit-testing, unit-test
Musicplayer
Implemented using Clean Arch, MVVM, LiveData, Room, Koin, Coil, Service, Notification and ExoPlayer
Stars: ✭ 413 (+1190.63%)
Mutual labels:  unit-testing, mockito
Tcunit
An unit testing framework for Beckhoff's TwinCAT 3
Stars: ✭ 74 (+131.25%)
Mutual labels:  unit-testing, unit-test
EntityFrameworkCore.AutoFixture
A library aimed to minimize the boilerplate required to unit-test Entity Framework Core code using AutoFixture and in-memory providers.
Stars: ✭ 31 (-3.12%)
Mutual labels:  unit-testing, unit-test
Tvflix
TvFlix android app using Dagger Hilt, Coroutines, Flow, KTX, Jetpack(Room, ViewModel, Paging3, Lifecycle) based on MVVM architecture purely written in Kotlin
Stars: ✭ 286 (+793.75%)
Mutual labels:  unit-testing, mockito
Mockingbird
A convenient mocking framework for Swift
Stars: ✭ 302 (+843.75%)
Mutual labels:  unit-testing, mockito

TestIt

Build Status License

While TDD is a better approach for development, many projects don't practice it and end up with low test coverage.

This project is here to help you improve your test coverage by reducing the effort spent on writing boilerplate code, allowing you to focus on writing the actual tests.

Use TestIt to generate unit testing boilerplate from kotlin files.

Getting Started

While you can run ./gradlew run --args "filepath", it might be more convenient to set up a shortcut to the provided helper script:

Install

  1. Get HomeBrew
  2. Run brew install coreutils
  3. Create a symbolic link: sudo ln -s /path/to/testit /usr/local/bin

Note: your project would need to include mockito 2 and mockito-kotlin or MockK.

Usage

Once installed, running TestIt is as simple as

testit path/to/file.kt

Or, to generate parameterized tests:

testit -p path/to/file.kt

Output

TestIt generates a test file in the default expected path.

For example, when run against itself (testit app/src/main/java/com/mitteloupe/testit/TestIt.kt) - see source file - it generates the below file at app/src/test/java/com/mitteloupe/testit/TestItTest.kt:

package com.mitteloupe.testit

import com.mitteloupe.testit.config.PropertiesReader
import com.mitteloupe.testit.file.FileProvider
import com.mitteloupe.testit.generator.TestFilePathFormatter
import com.mitteloupe.testit.generator.TestsGeneratorFactory
import com.mitteloupe.testit.model.ClassTestCode
import com.mitteloupe.testit.parser.KotlinFileParser
import org.mockito.kotlin.mock
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner

@RunWith(MockitoJUnitRunner::class)
class TestItTest {
    private lateinit var cut: TestIt

    @Mock
    lateinit var propertiesReader: PropertiesReader

    @Mock
    lateinit var fileProvider: FileProvider

    @Mock
    lateinit var kotlinFileParser: KotlinFileParser

    @Mock
    lateinit var testFilePathFormatter: TestFilePathFormatter

    @Mock
    lateinit var testsGeneratorFactory: TestsGeneratorFactory

    @Before
    fun setUp() {
        cut = TestIt(propertiesReader, fileProvider, kotlinFileParser, testFilePathFormatter, testsGeneratorFactory)
    }

    @Test
    fun `Given _ when getTestsForFile then _`() {
        // Given
        val fileName = "fileName"

        // When
        val actualValue = cut.getTestsForFile(fileName)

        // Then
        TODO("Define assertions")
    }

    @Test
    fun `Given _ when saveTestsToFile then _`() {
        // Given
        val sourceFileName = "sourceFileName"
        val classTestCode = mock<ClassTestCode>()

        // When
        cut.saveTestsToFile(sourceFileName, classTestCode)

        // Then
        TODO("Define assertions")
    }

    @Test
    fun `Given _ when showHelp then _`() {
        // Given

        // When
        cut.showHelp()

        // Then
        TODO("Define assertions")
    }
}

Features

  • Automatically compiles a list of required imports
  • Supports multiple classes in one Kotlin file
  • Supports overloaded functions
  • Supports both mockito 2 and MockK
  • Generates test code for abstract classes
  • Generates test code for extension functions
  • Generates test code for static functions
  • Generates parameterized tests code
  • Generates test code for exceptions
  • Configurable

Acknowledgments

This code uses a JAR from kotlin-grammar-tools to parse Kotlin code.

Created by

Eran Boudjnah

License

MIT © Eran Boudjnah

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].