Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 18 04:45
    scala-steward opened #392
  • Sep 18 04:45
    scala-steward opened #391
  • Sep 17 21:16
    scala-steward opened #390
  • Sep 17 08:07
    iRevive commented #387
  • Sep 17 07:19
    iRevive commented #387
  • Sep 17 06:15
    Baccata commented #387
  • Sep 16 22:21
    scala-steward opened #389
  • Sep 16 21:42
    Baccata commented #387
  • Sep 16 21:39
    Baccata opened #388
  • Sep 16 21:38

    Baccata on facilitate-monad-transformer-suites

    Play with "provider"-fingerprin… (compare)

  • Sep 16 18:27
    iRevive commented #387
  • Sep 16 18:25
    iRevive reopened #387
  • Sep 16 18:23
    iRevive closed #387
  • Sep 16 17:15
    Baccata commented #387
  • Sep 16 16:30
    iRevive edited #387
  • Sep 16 16:30
    iRevive edited #387
  • Sep 16 15:35
    iRevive edited #387
  • Sep 16 15:34
    iRevive opened #387
  • Sep 14 20:31
    scala-steward opened #386
  • Sep 13 20:40

    keynmol on master

    Update scalafmt-core to 3.0.3 (… (compare)

Jakub Kozłowski
@kubukoz:matrix.org
[m]
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
I was gonna get on your case for a yet another project you started but this one seems mature - almost a month old :D
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
Right, I misunderstood the semantics you wanted (implementation threw me off)
Jakub Kozłowski
@kubukoz:matrix.org
[m]
well this one is for a talk
Luís Campos
@LLCampos
Is there some repo out there comparing all current main Scala test libraries? Thinking about creating one.
Anton Sviridov
@velvetbaldmime:matrix.org
[m]

Not that I know of.

I know ecosystem is usually represented at https://github.com/lauris/awesome-scala#testing (to which we should add weaver at some point tbh)

That repo is such an awesome rabbit hole - I spent hours finding a random library from 2015 and playing with it

all current main Scala test libraries

It's also a moving target - it's like saying "comparing all json libraries" :D once you finish a writeup you need to add a new one

Luís Campos
@LLCampos
Ah, nice repo!
Yeah, my ideia would be to have something to help people understand the difference between the test libraries, what's the selling point for which one, etc
Olivier Mélois
@Baccata

There was an article a few weeks ago that aimed at doing that : https://ivan-kurchenko.medium.com/testing-with-scala-libraries-landscape-61b4c6403455

It was focused on good old unit-testing, and didn't talk about weaver / zio-test / distage-testkit

I don't dislike the idea but obviously I don't think we (weaver maintainers) can offer a very neutral point of view on the subject, haha
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
My very neutral view is that people should just use weaver for everything forever because it's the best and super-duper-cool 🤷
Olivier Mélois
@Baccata
xD
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
It's hard to be unbiased, but someone's gotta do it :D
Luís Campos
@LLCampos
@Baccata, thanks for the link! :)
Luís Campos
@LLCampos
Ok, first stab at it: https://github.com/LLCampos/state-of-the-art-scala-testing/ Is weaver-test well represented?
Kai
@neko-kai
You guys should check out (distage-testkit](https://izumi.7mind.io/distage/distage-testkit) - which has all the features of weaver, plus docker support and principled cross-suite resource sharing (no static objects and no global state) and appeared earlier too.
Olivier Mélois
@Baccata
Yup, I even name-dropped it a few messages ago :)
@LLCampos yeah it's a fair representation. There's a few things that are slightly inaccurate, ie there's more customisability than we document, but since we don't document it it's only fair to describe it as you do ;)
Kai
@neko-kai
Documentation is always the hardest part :(
Luís Campos
@LLCampos
Ah! Might be worth to create a issue listing what docs are missing?
Anton Sviridov
@velvetbaldmime:matrix.org
[m]

I'm not sure what Oli had in mind, but it's probably mostly for integrating new functionality into weaver's output rendering - so it's a fairly obscure feature which is better served by examples :)

hoping to produce one relatively soon.

Olivier Mélois
@Baccata
There's also the fact that we're still somewhat experimenting with stuff internally and haven't reached a state where we can guarantee backward compat (we try to be good citizens and avoid breaking source compat around everything that's documented). We're gonna try to enforce bincompat a little after the release of Scala 3 (at least for the core modules and the effect integrations), but in the meantime, leaving stuff undocumented is an okay compromise I think
Luís Campos
@LLCampos

With specs2 I can do the following to run tests through console:

java -cp 'jars/it/*:jars/*:jars/main/*' -Dfilesrunner.basepath=sources org.specs2.runner.files

Is there anything similar for weaver?

There's this, but it is one extra step (I have to create a main file) than the above
Olivier Mélois
@Baccata
@LLCampos not out of the box no. I personally use bloop to run tests through the terminal (but that involves having a build tool that outputs bloop configuration)
Luís Campos
@LLCampos
Yeah. I need something like the above for my work CI/CD environment. On the top of your head, would it be something possible to implement in the current codebase? If yes, I might have a go at it.
Olivier Mélois
@Baccata

I mean, everything's possible ... but I don't think it's something I'd want to maintain.

Regarding the implementation, the difficulty has to do with finding the test classes without the kind of metadata that is typically produced by build tools. I don't know how specs2 does it.

The abstract standalone runner you found in the weaver codebase gives you an example of how you can run suites and collect their results once you have the instances.

Anton Sviridov
@velvetbaldmime:matrix.org
[m]

We've just released 0.6.3/0.7.3 with Scala 3 final 🎉 The RC-chasing is over :)

No other changes in the release apart from some upgrades.

Zsolt Szilagyi
@esgott
Hi all, I am trying to use weaver-test with breeze (the linear algebra library). I've got stuck making expect to work with their DenseMatrix. What I'm trying to compile is expect(DenseMatrix((1, 2), (3, 4)) == DenseMatrix((1, 2), (3, 4))), and the error I get is
error] -- [E007] Type Mismatch Error: /home/esgott/Repos/spottle/core/src/test/scala/com/github/esgott/spottle/core/FanoPlaneTest.scala:16:4 
[error] 16 |    expect(DenseMatrix((1, 2), (3, 4)) == DenseMatrix((1, 2), (3, 4)))
[error]    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |Found:    breeze.linalg.DenseMatrix[Int]
[error]    |Required: (implicit rl: breeze.linalg.support.LiteralRow[(Int, Int), Int], man: 
[error]    |  scala.reflect.ClassTag[Int]
[error]    |, zero: breeze.storage.Zero[Int]): breeze.linalg.DenseMatrix[Int]
[error]    | This location contains code that was inlined from FanoPlaneTest.scala:16
My guess is that I should probably write a custom expectation rule for DenseMatrix, but it's not clear to me how to do that, or if that is really my problem. Can you help me with this?
Zsolt Szilagyi
@esgott
it works like this:
val m1 = DenseMatrix((1, 2), (3, 4))
val m2 = DenseMatrix((1, 2), (3, 4))
expect(m1 == m2)
Olivier Mélois
@Baccata
@esgott are you using Scala 3 ? And which version of weaver are you on ?
Zsolt Szilagyi
@esgott
@Baccata Yes, Scala 3.0.0 and Weaver 0.7.4
Olivier Mélois
@Baccata
So that's a bug with expecty (which weaver depends on). We thought it was fixed but looks like the fix might not be exhaustive...
Olivier Mélois
@Baccata
The bug manifest itself when calling methods that have implicit parameters within "expect". For equality checks though, you can circumvent that problem with expect.same(a, b)
Sean Kwak
@cosmir17

Hi, I am using expect method(Expectations.Helpers) in weaver.

expect.same(json.dropNullValues, expectedBody.asJson.dropNullValues)
[error]   Values not equal: (modules/tests/src/it/scala/HttpSuite.scala:24)
[error] 
[error]   {                                                           |  ["]{[\][n][\"][exchange][\"][ ][:][ ][1][.][164659][,\][n][\"][amount][\"][ ][:][ ][119][.][4940134][,\][n][\"][original][\"][ ][:][ ][102][.][6][\][n][}]["]
[error]   [  "exchange" : 1.164659,]         |  
[error]   [  "amount" : 119.4940134,]    |  
[error]   [  "original" : 102.6]                     |  
[error]   [}]                                                        |

How can I make json.dropNullValues to print in the format on the left?

Olivier Mélois
@Baccata
Hi @cosmir17 , you can customise the strings used in this rendering by implementing a custom cats.Show instance for the type you're manipulating
Sean Kwak
@cosmir17
@Baccata Thank you for your response :) I think it's the right format in terms of the notations. It's just that the notations are not being processed to make it human readable (/n => new line, [] etc)..
Sean Kwak
@cosmir17
I fixed it somehow. Thank you for your response.
Maksim Ochenashko
@iRevive

Hi everyone!

I'm using weaver 7.0.4, Scala is 3.0.1.

build.sbt:

testFrameworks  := Seq(new TestFramework("weaver.framework.CatsEffect"))

I'm willing to use weaver with a compound effect:

final case class RaisedError(error: Throwable, pos: Position, errorId: String)
final case class LogContext(traceId: String, extra: Map[String, String])

type WithLogContext[F[_], A] = Kleisli[F, LogContext, A]
type WithError[A]            = EitherT[IO, RaisedError, A]
type Eff[A]                  = WithLogContext[WithError, A]

trait AppSuite extends MutableFSuite[Eff] {

  abstract class CatsEffect extends SimpleMutableIOSuite {
    val translate = new cats.arrow.FunctionK[Eff, cats.effect.IO] {
      def apply[A](fa: Eff[A]): IO[A] = /* translate to IO */
    }
    override def spec(args: List[String]): fs2.Stream[cats.effect.IO, TestOutcome] =
      self.spec(args).translate(translate)
  }

}

// this object is not discovered by the runner
object MySuite extends AppSuite {
  test("some test") { ... }
}

// this object is discovered
object MySuiteCE extends MySuite.CatsEffect

Unfortunatelly, I need to expose the CatsEffect object (object MySuiteCE extends MySuite.CatsEffect). Otherwise the suite is not discovered by weaver.framework.CatsEffect.

Can I reduce the boilerplate somehow?

Olivier Mélois
@Baccata
@iRevive interesting question. I'll give it a think tomorrow, but intuitively I think it'd be easier to have a def myTest(name: TestName)(eff: Eff[Expectations]) = test(name)(translate(eff)) in a IOSuite and use that.
depends about whether you're trying to use sharedResources in terms of Eff, and where you're wanting to inject the log context
Maksim Ochenashko
@iRevive

I tried to implement a separate method def testF(...)(eff: Eff[Expectation).

I faced several issues:
1) I need dual constructor for my resources. E.g. def loadApp[F[_], G[_]](config: Config): F[Application[G]]). Where F = IO, and G = Eff.
2) Scalacheck checkers do not work out of the box. forall offers only IO methods (which is expected).

Olivier Mélois
@Baccata
Mmm I see. Could you create a ticket ? I think your usecase is worth supporting out of the box.
I'm glad you found a workaround, it's a tricky one
Maksim Ochenashko
@iRevive
Sure, I will make a ticket
Maksim Ochenashko
@iRevive
If we find a working option I can try to contribute the solution