Coder Social home page Coder Social logo

expekt's People

Contributors

hastebrot avatar meoyawn avatar sblundy avatar winterbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expekt's Issues

Arrays

As far as i see there is no easy way to compare the content of two arrays.
e.g. I have two ByteArrays.

I would expect the following to work:
written.readBytes().should.equal(data)

It just compares the references and fails.

This one works:
written.readBytes().toList().should.equal(data.asList())

That's a little bit ugly in my opinion.

Lambda-based assertions for collections

Borrowing from Fluent Assertions, it would be quite convenient to have lambda-based assertions for collections:

class Thing(val name)
val collection = arrayListOf(Thing("a"), Thing("b"), Thing("c"))

collection.should.contain({ it.name == "a" })

Currently it's possible to replicate this using list extensions, but it is not as readable, and will not give as descriptive message:

collection.firstOrNull({ it.name == "a" }).should.not.be.`null`

Not an issue, just a fan

Apologies for the noise, but just wanted to voice my appreciation for this project.

I've been using it for a long time (1.5 years?), and it's become central to all my tests. Thanks so much for your work.

.should.match not working with multiple line

Is there anyway you can support multi-line matching? ๐Ÿ˜„

"""
    This is
    some multiline 123
    text
""".trimIndent().should.match("some multiline \\d+".toRegex(RegexOption.MULTILINE))

No way to validate thrown exceptions

It seams that framwork doesn't provide any way to check that tested code throws exception of specific kind. I guess test code can use try/catch, do fail if rich the end of try and do assertions in the catch clause. However this seams clunky and won't give correct nice message in case of failure.

I think the syntax for exceptions could be: expect(MyException::class).thrownBy {...}
If thrownBy returns the exception following code can validate details about it (message, cause, etc.).

Alternative syntax may be expect {...}.throws(MyException::class).

ExpectAny should be extendable

Subject and words of ExpectAny should be accessible publicly so that we can write extension functions for own assertions on the subject with own words being logged.

The following for example checks that two collections are equal while ignoring the order of the elements:

fun <Element> ExpectCollection<Element>.equalIgnoringOrder(expected: Collection<Element>) =
	apply {
		satisfy { subject ->
			val subjectList = subject.toList()
			val expectedList = expected.toList()

			subjectList.size == expectedList.size 
				&& subjectList.all(expectedList::contains) 
				&& expectedList.all(subjectList::contains)
		}
	}

Due to lack of access to subject the function satisfy must be used to access the subject.
Due to lack of access to words a failure would log satisfy predicate instead of something more helpful like equalIgnoringOrder $expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.