Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests of cacctoos is not oop #588

Closed
neonailol opened this issue Jan 29, 2018 · 44 comments
Closed

Tests of cacctoos is not oop #588

neonailol opened this issue Jan 29, 2018 · 44 comments
Labels

Comments

@neonailol
Copy link
Contributor

neonailol commented Jan 29, 2018

Right now tests use alot of static function from matchers,
Maybe they should be more oop style, like let's take this example

    @Test
    public void iteratesEmptyList() {
        final List<String> list = new LinkedList<>();
        MatcherAssert.assertThat(
            "Can't iterate a list",
            new And(
                new Mapped<String, Scalar<Boolean>>(
                    new FuncOf<>(list::add, () -> true), Collections.emptyList()
                )
            ),
            new ScalarHasValue<>(
                Matchers.allOf(
                    Matchers.equalTo(true),
                    new MatcherOf<>(
                        value -> {
                            return list.isEmpty();
                        }
                    )
                )
            )
        );
    }

in oop style this would be

    @Test
    public void iteratesEmptyList() {
        final List<String> list = new LinkedList<>();
        MatcherAssert.assertThat(
            "Can't iterate a list",
            new And(
                new Mapped<String, Scalar<Boolean>>(
                    new FuncOf<>(list::add, () -> true), Collections.emptyList()
                )
            ),
            new ScalarHasValue<>(
                new AllOf<Boolean>(
                    new IterableOf<>(
                        new IsEqual<>(true),
                        new MatcherOf<>(
                            value -> {
                                return list.isEmpty();
                            }
                        )
                    )
                )
            )
        );
    }

or this is overkill?

@0crat
Copy link
Collaborator

0crat commented Jan 29, 2018

@yegor256/z please, pay attention to this issue

@yegor256
Copy link
Owner

@neonailol where will we get all those matchers?

@neonailol
Copy link
Contributor Author

neonailol commented Jan 29, 2018

@yegor256 they already exists in org.hamcrest.core, all of them are public, and since this library has package for tests, if some matchers is missing, its implementations it should go there
for example here is IsEqual matcher

@yegor256
Copy link
Owner

@neonailol sounds like a good idea, but we can't just replace all static calls with classes. Very soon somebody will add them back again. We have to create some validator, that will crash the build if Matchers.* is used. Any ideas?

@neonailol
Copy link
Contributor Author

neonailol commented Jan 29, 2018

@yegor256 there is plugin for maven forbidden-apis

Sample configuration: add this profile to pom.xml

<profile>
      <id>forbiddenapis</id>
      <build>
        <plugins>
          <plugin>
            <groupId>de.thetaphi</groupId>
            <artifactId>forbiddenapis</artifactId>
            <version>2.4.1</version>
            <configuration>
              <failOnUnsupportedJava>false</failOnUnsupportedJava>
              <signaturesFiles>
                <signaturesFile>./src/test/resources/org/cactoos/forbidden.txt</signaturesFile>
              </signaturesFiles>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>testCheck</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

create file ./src/test/resources/org/cactoos/forbidden.txt with content

@defaultMessage Do not use static methods
org.hamcrest.Matchers

run maven goal forbiddenapis:testCheck, and you wold have something similar to this

[ERROR] Forbidden class/interface use: org.hamcrest.Matchers [Do not use static methods]
[ERROR]   in org.cactoos.collection.BehavesAsCollection (BehavesAsCollection.java:64)
[ERROR] Forbidden class/interface use: org.hamcrest.Matchers [Do not use static methods]
[ERROR]   in org.cactoos.collection.BehavesAsCollection (BehavesAsCollection.java:64)
[ERROR] Forbidden class/interface use: org.hamcrest.Matchers [Do not use static methods]
[ERROR]   in org.cactoos.collection.BehavesAsCollection (BehavesAsCollection.java:68)
[ERROR] Forbidden class/interface use: org.hamcrest.Matchers [Do not use static methods]

plugin also includes some bundled signatures for jdk unsafe methods, but for this examaple i excluded them

also it can match specific methods, link to example

@llorllale
Copy link
Contributor

@neonailol btw, since 0.33 all matchers for cactoos were moved to new project llorllale/cactoos-matchers.

@llorllale
Copy link
Contributor

@neonailol so let's start by forbidding those APIs and refactoring as necessary

@llorllale
Copy link
Contributor

@0crat in

@0crat 0crat added the scope label May 12, 2018
@0crat
Copy link
Collaborator

0crat commented May 12, 2018

@0crat in (here)

@llorllale Job #588 is now in scope, role is DEV

@0crat
Copy link
Collaborator

0crat commented May 12, 2018

Bug was reported, see §29: +15 point(s) just awarded to @neonailol/z

@0crat
Copy link
Collaborator

0crat commented May 12, 2018

The score of @neonailol/z -271 is too low and will be reset: +271 point(s) just awarded to @neonailol/z

@yegor256
Copy link
Owner

@llorllale I like the idea. @neonailol thanks!

@0crat
Copy link
Collaborator

0crat commented May 16, 2018

The job #588 assigned to @victornoel/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this

@victornoel
Copy link
Collaborator

@llorllale shouldn't the maven configuration go into jcabi-parent instead? or shouldn't we have a parent for cactoos projects maybe?

@llorllale
Copy link
Contributor

@victornoel we'll use this project as our guinea pig. If the idea holds, maybe it'll spread to other projects as well

victornoel added a commit to victornoel/cactoos that referenced this issue May 19, 2018
victornoel added a commit to victornoel/cactoos that referenced this issue May 19, 2018
@victornoel
Copy link
Collaborator

@0crat waiting for #882

@0crat
Copy link
Collaborator

0crat commented May 19, 2018

There is an unrecoverable failure on my side. Please, submit it here:

PID: 4@0caff0cf-8894-47fa-aeff-666b2b14aaac, thread: BkParallel-8
com.zerocracy.pm.Claims[112] java.lang.IllegalStateException: Duplicate claims are not allowed in [C63314D6Z](https://www.0crat.com/p/C63314D6Z), can't add this XML to 5 existing ones:
<?xml version="1.0" encoding="UTF-8"?>
<claim id="1391435999">
   <created>2018-05-19T14:35:38.348Z</created>
   <type>Register impediment</type>
   <token>github;yegor256/cactoos;588;390409117</token>
   <author>victornoel</author>
   <params>
      <param name="job">gh:yegor256/cactoos#588</param>
      <param name="repo">yegor256/cactoos</param>
      <param name="issue">588</param>
      <param name="comment">390409117</param>
   </params>
</claim>

1.0-SNAPSHOT: Issue: #588, Comment: 390409117

@0crat
Copy link
Collaborator

0crat commented May 19, 2018

@0crat waiting for #882 (here)

@victornoel The impediment for #588 was registered successfully by @victornoel/z

@0crat
Copy link
Collaborator

0crat commented May 19, 2018

@0crat waiting for #882 (here)

@victornoel Job #588 is already on hold

@victornoel
Copy link
Collaborator

@0crat status

@0crat
Copy link
Collaborator

0crat commented May 19, 2018

@0crat status (here)

@victornoel This is what I know about this job, as in §32:

@0pdd
Copy link
Collaborator

0pdd commented May 28, 2018

@neonailol 2 puzzles #902, #903 are still not solved.

@victornoel
Copy link
Collaborator

@neonailol #882 has been merged, this issue can now be closed

@0crat
Copy link
Collaborator

0crat commented May 28, 2018

@elenavolokhova/z please review this job completed by @victornoel/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed

@0crat 0crat removed the scope label May 28, 2018
@0crat
Copy link
Collaborator

0crat commented May 28, 2018

The job #588 is now out of scope

@elenavolokhova
Copy link

@0crat quality good

@0crat
Copy link
Collaborator

0crat commented May 28, 2018

Quality review completed: +8 point(s) just awarded to @elenavolokhova/z

@victornoel
Copy link
Collaborator

@llorllale 0crat didn't award me my +35 points :)

@llorllale
Copy link
Contributor

@0crat pay 35min @victornoel

@0crat
Copy link
Collaborator

0crat commented Jun 6, 2018

@0crat pay 35min @victornoel (here)

@llorllale The project is under-funded, you can't do it now, see §49

@victornoel
Copy link
Collaborator

@llorllale I think we can try again?

@llorllale
Copy link
Contributor

@0crat pay 35min @victornoel

@0crat
Copy link
Collaborator

0crat commented Jun 29, 2018

Direct payment from @llorllale/z: +35 point(s) just awarded to @victornoel/z

@0crat
Copy link
Collaborator

0crat commented Jun 29, 2018

Direct payment to @victornoel/z in #588, which is discouraged, see §49: -20 point(s) just awarded to @llorllale/z

@victornoel
Copy link
Collaborator

@llorllale thanks

@0pdd
Copy link
Collaborator

0pdd commented Sep 20, 2018

@neonailol 2 puzzles #902, #951 are still not solved; solved: #903.

@0pdd
Copy link
Collaborator

0pdd commented Nov 4, 2018

@neonailol the puzzle #951 is still not solved; solved: #902, #903.

@0pdd
Copy link
Collaborator

0pdd commented Mar 14, 2019

@neonailol the puzzle #1082 is still not solved; solved: #902, #903, #951.

@0pdd
Copy link
Collaborator

0pdd commented Apr 25, 2019

@neonailol the puzzle #1119 is still not solved; solved: #1082, #902, #903, #951.

@0pdd
Copy link
Collaborator

0pdd commented Jul 20, 2019

@neonailol the puzzle #1166 is still not solved; solved: #1082, #1119, #902, #903, #951.

@0pdd
Copy link
Collaborator

0pdd commented Nov 3, 2019

@neonailol 2 puzzles #1222, #1223 are still not solved; solved: #1082, #1119, #1166, #902, #903, #951.

@0pdd
Copy link
Collaborator

0pdd commented Nov 6, 2019

@neonailol the puzzle #1223 is still not solved; solved: #1082, #1119, #1166, #1222, #902, #903, #951.

@0pdd
Copy link
Collaborator

0pdd commented Sep 4, 2020

@neonailol the puzzle #1434 is still not solved; solved: #1082, #1119, #1166, #1222, #1223, #902, #903, #951.

@0pdd
Copy link
Collaborator

0pdd commented Apr 14, 2021

@neonailol the puzzle #1583 is still not solved; solved: #1082, #1119, #1166, #1222, #1223, #1434, #902, #903, #951.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants